Posts 2 Posts
[resolved] Loop on loop - taxonomy template (3 posts)

  1. Aurélien Denis
    Posted 4 years ago #


    I'm looking for a little bit of help... :-)

    My objectif is to show connected posts to a custom post filtering on meta query (custom field).

    Here is the initial code : http://pastebin.com/Thhe6EbR

    The problem stars on line 33. Multiple data are displayed. I need to show just one data. I already do this on single custom post but the same code do not work on a taxonomy page.

    I'm using this piece of code just after line 30 :

    $connected = new WP_Query( array(
    'connected_type' => 'saisons_to_sejours',
    'connected_items' => get_queried_object_id(),
    'nopaging' => true,
    'meta_query' => array(
    'relation' => 'AND',
    'key' => 'date_debut',
    'value' => $today,
    'compare' => '<='
    'key' => 'date_fin',
    'compare' => '>=',
    'value' => $today,


    ) );

    Not sure I'm clear in my explanations...


  2. scribu
    Plugin Author

    Posted 4 years ago #

    So, you're saying the WP_Query call works fine on other templates.

    The issue is that, on category template, get_queried_object_id() returns the current category, not a post.

    You just need to replace it with $post, like you did in your initial code.

  3. Aurélien Denis
    Posted 4 years ago #

    You're the King! Lost one entire day looking for my error. :D

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.