WordPress.org

Support

Support » Themes and Templates » Conditional tag behavior in custom WP_Query loops

Conditional tag behavior in custom WP_Query loops

  • I have a custom loop which uses WP_Query to create a new query object, like so (if there’s any errors in the code it’s because I’m typing it on the fly):

    $custom_query = new WP_Query($args);

    then I have a loop, like so:

    if($custom_query) { while($custom_query->have_posts()... } }

    within the loop, I have several template parts that are included, and within these template parts there are conditional tags. Specifically there are a lot of “is_singular()”s. These are returning true because the custom loop is on a single page, but I want them to honor the parameters of the custom query, and return “false”. Is this possible without doing some sort of awful hack?

    I’d like to avoid using ‘query_posts()’ because that would involve hacking a 3rd party plugin, but if that’s truly the only way, I would love to know before spending any more days searching Google.

  • The topic ‘Conditional tag behavior in custom WP_Query loops’ is closed to new replies.
Skip to toolbar