## plugins – Getting Trying to get property ‘ID’ of non-object in and Undefined index: ID

Question

I have below the code and I have to get the post id using the post title. I am getting multiple post titles and using explode.

        $atts['speakersname']='abc,xyz,prq'; // post title$getspeakertitle=explode( ',', $atts['speakersname']);$speakerpostid[]='';
foreach ($getspeakertitle as$key => $value) {$speakerpostid[] = get_page_by_title( $value, OBJECT, 'speaker' ); } echo"<pre>"; print_r($speakerpostid);
print_r($speakerpostid->ID); print_r($speakerpostid['ID']);


I am displaying the output then I am getting an error

print_r($speakerpostid->ID);  Notice: Trying to get property ‘ID’ of non-object in print_r($speakerpostid['ID']);


Notice: Undefined index: ID in

i have to pass the ID to the below post

$s_post = get_posts(array( 'showposts' => 10, 'post_type' => 'speaker', 'post_status' => 'publish', 'post__in' => array('34'), // ID here ) );  I have directly try 'post__in' => array($atts['speakersname']) but it’s not working

My main aim is, I have to show the post which is in the \$atts['speakersname']

0
3 weeks 2022-11-12T10:12:52-05:00 0 Answers 0 views 0