• Resolved Vyath

    (@vyath)


    The plugin works great with wp_query, but I’m unable to get it to work using get_posts

    My code is as follows:

    `$countryargs =array(
    ‘orderby’ => ‘title’,
    ‘order’ => ‘ASC’,
    ‘post_type’ => ‘country’,
    ‘posts_per_page’=>-1,
    ‘each_connected’ => array(
    ‘post_type’ => ‘distributor’
    ));

    $loop = get_posts( $countryargs);
    foreach ($loop as $post) : setup_postdata($post);
    `
    and then get connected posts with
    foreach ( $post->connected as $distributor )

    but I get

    Warning: Invalid argument supplied for foreach() in /…path…/template_wheretobuy.php on line 67

    on the line trying to get connected posts

    What should I do?

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author scribu

    (@scribu)

    You should add:

    $countryargs = array(
    'suppress_filters' => false,
    ...
    Thread Starter Vyath

    (@vyath)

    Thank you for the fast reply!

    this is really strange –
    if I add ‘suppress_filters’ => false
    then it works

    BUT

    ‘orderby’ => ‘title’
    refuses to work, meaning the posts are ordered only by date…

    Plugin Author scribu

    (@scribu)

    Try deactivating all other plugins, to make sure it’s a problem with P2P.

    Thread Starter Vyath

    (@vyath)

    You’re right!
    the problem was actually in “Custom Content Type Manager”

    Thank you for your help and sorry the inconvenience ??

    Thoughts on adding a suppress_filters => false by default to WP_Query so get_posts works out of box with the plugin? Not sure if possible but would be nice.

    Plugin Author scribu

    (@scribu)

    'suppress_filters' => false already is the default in WP_Query.

    get_posts() defaults to 'suppress_filters' => true for compatibility reasons (it didn’t use WP_Query initially).

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Posts 2 Posts] Using p2p with get_posts’ is closed to new replies.