Stack Overflow Asked by German mazzaferro on January 1, 2022
PHP Notice: Trying to get property ‘post_title’ of non-object in line 217
Line 217: <a href="'. (!$is_placeholder?$image[0]:'javascript:void(0);') . '" ' . (!$is_placeholder?' rel="prettyPhoto"':'') . '><img src="'. $image[0] . '" title="' . $value->post_title . '" style="height:80px;width:80px;"/></a>
Its been many years since I was a developer, so please don’t be mean, I need a hand with this.
This is wordpress 5.3.2 with woocommerce 4.0. Php 7.2 with cpanel in centOS
Seems like your $value variable is not an instance of WP_Post.
If your code is inside the WP loop or in a single post or page, you can use get_the_title()
instead of $value->post_title
.
Else, you have to set the variable with the post, like this:
<?php $value = get_post(100); // change '100' with the right post ID ?>
<a href="'. (!$is_placeholder?$image[0]:'javascript:void(0);') . '" ' . (!$is_placeholder?' rel="prettyPhoto"':'') . '><img src="'. $image[0] . '" title="' . $value->post_title . '" style="height:80px;width:80px;"/></a>
Answered by Luca Rosaldi on January 1, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP