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
1 Asked on January 1, 2022 by harish
1 Asked on January 1, 2022 by you-hock-tan
3 Asked on January 1, 2022 by chetan-suri
1 Asked on January 1, 2022 by german-mazzaferro
2 Asked on January 1, 2022
1 Asked on January 1, 2022 by ljcq-09
1 Asked on January 1, 2022 by user11336100
2 Asked on January 1, 2022 by maxsteel
1 Asked on January 1, 2022 by shaul-sondak
2 Asked on January 1, 2022 by undefinedkid01
0 Asked on January 1, 2022 by programmingislife
0 Asked on January 1, 2022 by pale-blue-dot
2 Asked on January 1, 2022 by roel-thijssen
1 Asked on January 1, 2022 by davec
1 Asked on January 1, 2022 by kdynamic
0 Asked on December 30, 2021 by sateesh-gollapudi
2 Asked on December 30, 2021 by jamheadart
Get help from others!
Recent Questions
Recent Answers
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP