I tried to write something like this, but set in the functions of child theme I got php error:
I know there are bugs here but I say ‘something like this’
$current_title = get_the_title();
$post = new WP_Query( array( 'post_type' => 'attivita', 'posts_per_page' => -1 ) );
function get_the_title( $post = 0 ) {
$post = get_post( $post );
$post_title = isset( $post->post_title ) ? $post->post_title : '';
$post_id = isset( $post->ID ) ? $post->ID : 0;
return apply_filters( 'the_title', $post_title, $post_id );
if ($current_title == $post_title) {
$post_id == $cpt_id; }
else {
echo 'no CPT found!';
}
}
The current_title comes from the post of promo category and the cpt_id is the post_id of the CPT ‘attivita’ that has the same title of the current post in prtomo category. Getting the cpt_id I can use the fields groups of the cpt attivita and get the field content for each value set in cpt dashboard