Forums

Posts 2 Posts
[resolved] Category Archive Pages With Several Post Types (6 posts)

  1. randellbrantley
    Member
    Posted 1 year ago #

    I am building a complex site and using this plugin.

    I am using each_connected() to modify $wp_query and p2p_list_posts() to display the results (as described in the wiki).

    This works fine on pages with modified queries to archive a single custom post_type, archive.php pages showing a single post_type and even archive-post_type.php pages showing a single post_type.

    In fact I have four types of connection linking different post_types together and use each_connected() four times on each page regardless of whether the post_type being queried uses all of them or not. This works on pages as long as I am only querying 1 post_type.

    The problem is I have made 'categories' available to all of my post_types and have changed the query on the category.php template page to include all of these. As soon as I am querying more than 1 type of post_type the plugin no longer works. Looking at the $wp_query object being returned it appears that each_connected() has failed to do anything.

    I have tried everything I can think of and just can't get p2p_list_posts() to show anything on this category archive page which displays a mixture of post_types.

    Please help, I am stumped.

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

  2. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    It would be useful to have the following info:

    * the p2p_register_connection_type() call
    * the WP_Query with multiple post types call
    * the associated each_connected() calls

    Please post these bits of code in a http://pastebin.com/

  3. randellbrantley
    Member
    Posted 1 year ago #

    Pasted here (if I did it right) http://pastebin.com/77zk9tSK

  4. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, thanks. So you're using 'post_type' => 'any'. I'll do some tests on my end.

    PS: You know you can register all the connection types inside the same function, right?

  5. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, so I implemented a fix in the development version (1.3-alpha2). Please try it out.

  6. randellbrantley
    Member
    Posted 1 year ago #

    First, WOW. It worked.

    Thank you very much for your fast work.

    Second, it had not crossed my mind that I could do the registering all in one function. Thank you again, my amateur code is a little neater now.

    Very nice plugin, thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic