• Resolved simisch

    (@simisch)


    Hi,
    I’ve set up a connection type ‘team_to_project’, in the single team view the connection works fine. Now I’m trying to run it in the archive page. Same code from single view (replacing get_queried_object() by $post) isn’t working.
    Switched to each_connected as written in Wiki. This is my code in the loop:

    p2p_type( 'team_to_project' )->each_connected( $wp_query);
    		foreach ( $post->connected as $post ) : setup_postdata( $post );
    			the_title();
    		endforeach;
    		wp_reset_postdata(); // set $post back to original post

    Using p2p Version 1.4.3 and murmur theme, running it in archive_team.php

    I am stuck and appreciate any help.

    Registration:

    function my_connection_types() {
    	p2p_register_connection_type( array(
    		'name' => 'team_to_project',
    		'from' => 'team',
    		'to' => 'project',
    		'admin_column' => 'any',
    		'admin_box' => 'any',
    		'reciprocal' => true, // the relation has no hierarchy
    		'sortable' => 'any',
    	) );
    }
    add_action( 'init', 'my_connection_types' );

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

Viewing 1 replies (of 1 total)
  • Thread Starter simisch

    (@simisch)

    It seems for now it’s the theme functions.php, a function that modifies the loop.
    remove:

    if( is_post_type_archive( 'team' ) ) {
    		$query->query_vars['posts_per_page'] = 6;
    		return;
    	}

    and the connections is displayed

Viewing 1 replies (of 1 total)
  • The topic ‘Trouble with loop’ is closed to new replies.