• On my functions.php I try to get specific post connections but I don’t get the connections and I’m not sure why. Any help?

    So far my function is such:

    function my_get_person_title( $post_id ) {
    
        $connections = new WP_Query( array(
            'connected_type' => 'business_to_people'
            'connected_items' => $post_id, // also tried here get_queried_object_id()
            'suppress_filters' => false,
            'nopaging' => true,
        ) );
    
        if ( $connections->have_posts() ) :
            while ( $connections->have_posts() ) : $connections->the_post();
                $title = get_post_meta( $post->ID, '_title', true );
                // do something else with $title but title is empty
            endwhile;
        endif;
    
        return true;
    }

    https://www.ads-software.com/plugins/posts-to-posts/

Viewing 1 replies (of 1 total)
  • Give this a try, you were also missing a comma after 'business_to_people' that I could see.

    function my_get_person_title( $post_id ) {
    
        $connections = new WP_Query( array(
            'connected_type' => 'business_to_people',
            'connected_items' => $get_queried_object(),
            'suppress_filters' => false,
            'nopaging' => true
        ) );
    
        if ( $connections->have_posts() ) :
            while ( $connections->have_posts() ) : $connections->the_post();
                $title = get_the_title();
                // do something else with $title but title is empty
            endwhile;
        endif;
    
        return true;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Get specific post connections’ is closed to new replies.