WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Trouble with loop (2 posts)

  1. simisch
    Member
    Posted 1 year ago #

    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' );

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. simisch
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags