WordPress.org

Ready to get started?Download WordPress

Forums

Conditional tag behavior in custom WP_Query loops (1 post)

  1. leeviathan
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic