That is the data of my downside:
Applied sciences used: Divi Theme – WordPress
Scope:
Present an Superior Customized Area of kind post_object associated to a selected submit.
Particulars:
- I’ve a customized submit kind referred to as nations which is an inventory of nations
- I’ve an Superior Customized Area referred to as nation of kind submit object that refers to that checklist of nations from the CPT
- I’ve a Customized Submit Sort referred to as Information the place I assign a rustic to every information utilizing the Superior Customized Area Nation
What I want:
I need to present within the entry of every information submit the nation related to that entry. When I attempt to use Divi’s dynamic content material I get the error: "Object of class WP_Post could not be converted to string".
My code:
I’ve made this shortcode nevertheless it reveals me an inventory of nations and does not present the nation assigned to the customized submit kind within the submit entry. Within the picture, you may see what I would like together with what I’ve for the time being.
That is my code:
add_shortcode( 'showpost', 'display_custom_post_type' );
perform display_custom_post_type(){
$args = array(
'post_type' => 'nations',
'$post->ID'
);
$string = '';
$question = new WP_Query( $args );
if( $query->have_posts() ){
$string .= '<ul>';
whereas( $query->have_posts() ){
$query->the_post();
$string .= '<li>' . get_the_title() . '</li>';
}
$string .= '</ul>';
}
wp_reset_postdata();
return $string;
}
Any concepts?