Thread Starter
Anonymous User 14978628
(@anonymized-14978628)
Looking in my debug i’ve also noticed the following errors:
PHP Notice: Undefined variable: post in /module-posts-blog-feed-loop.php on line 11
PHP Notice: Trying to get property of non-object in /module-posts-blog-feed-loop.php on line 11
which relates to this line
<a href="<?php echo get_permalink( $post->ID );?>">
PHP Notice: Undefined variable: post in /module-posts-blog-feed-loop.php on line 13
which relates to this line
$thumbnail_id = get_post_thumbnail_id( $post->ID );
The previous two errors
[22-Aug-2017 05:43:36 UTC] PHP Notice: Undefined index: class in /responsify-wp/includes/custom_media_query_rules.php on line 58
[22-Aug-2017 05:43:36 UTC] PHP Notice: Undefined index: class in /responsify-wp/includes/custom_media_query_rules.php on line 62
Relate to this section of code:
public function image_size_equals( $attributes, $value )
{
return is_integer( strpos($attributes['img']['class'], 'size-' . $value) );
}
public function image_size_not_equals( $attributes, $value )
{
return ! is_integer( strpos($attributes['img']['class'], 'size-' . $value) );
}
Which i recognize because i’m using custom media queries within the plugin using both the if equals and not equals variables for 2 separate rules.
Hi Marty!
Sorry for the late reply. I’ve noticed that the <select> elements in WordPress is a bit strange. You might have to go to your custom media queries, select your settings again in the <select> boxes and click save. Try that and see if the errors disappears!
The errors relating to get_permalink() and get_post_thumbnail_id() doesn’t have anything to do with RWP I think.
Thread Starter
Anonymous User 14978628
(@anonymized-14978628)
Hey Stefan, no worries. Will try selecting again as you suggested and see if that fixes it.
The other errors were part of a custom code you once gave for me manual insertion into the theme:
<a href="<?php echo get_permalink( $post->ID );?>">
<?php
$thumbnail_id = get_post_thumbnail_id( $post->ID );
echo rwp_img( $thumbnail_id, array(
'sizes' => array('homepage-grid', 'homepage-tablet', 'homepage-phone' ),
'attributes' => array(
'sizes' => '(min-width: 1366px) 603px, (min-width: 1024px) 507px, (min-width: 667px) 1036px, (min-width: 568px) 603px, 507px',
'alt' => get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true)
)
));
?>
</a>
And the errors relate to these lines:
<a href="<?php echo get_permalink( $post->ID );?>">
$thumbnail_id = get_post_thumbnail_id( $post->ID );
From what i could find online about the error i’m getting:
PHP Notice: Undefined variable: post
It seems to relate to the “$post” component. Actually, just searching this again now i found this (https://stackoverflow.com/questions/11520795/undefined-variable-post-php-and-mysql) which suggests using $_POST instead of $POST. Will try that out.
$post and $_POST is two different things. $post is a global variable in WordPress which contains the data of the current post, on a single page or within a loop for example.
https://codex.ww.wp.xz.cn/Function_Reference/$post
$_POST is a global PHP variable containing data that has been posted from a form.
PHP Notice: Undefined variable: post means that the code isn’t within a loop or on a single page. I can’t tell you any more without the whole context.
This has nothing to do with RWP itself though. I might be lazy, but since it’s just a warning and nothing breaks, I wouldn’t worry to much about it.
Thread Starter
Anonymous User 14978628
(@anonymized-14978628)
Ok, I’ve changed back Post to how it originally was. Using $_Post didn’t break anything, but it didn’t fix the issue either.
If this is just a warning and won’t break anything as you said then i’m happy to leave as is! Thanks!