Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Hi corinnepritchard,

    Absolutely! That’s fairly simple, but is done within the shortcode instead of the query interface.

    Example:

    [query slug=”my-query” args=”p={{post:ID}}”]

    There are a few more examples in the FAQ http://wordpress.org/plugins/query-wrangler/faq/ .

    Let me know how this works out for you,
    Jonathan

    Edit: whoops, used wrong token. Should be {{post:ID}}

    Thread Starter corinnepritchard

    (@corinnepritchard)

    Oh! Thank you for replying so quickly.

    And just saw your edit – phew! Was worried it wasn’t working.

    Is there a full list of those arguments somewhere as ‘p=’ etc, isn’t necessarily intuitive? (couldn’t see one on the link you gave but may just be being blind).

    Yours,

    Corinne

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Sure, there is a reference (sort of).

    Those arguments all come from the WP_Query class. http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

    Any parameter that is not an array should work.

    For example, to limit by author:

    The ‘author’ parameter accepts string values, so it will work.
    $query = new WP_Query( 'author=2,6,17,38' );

    As a QW query —
    [query slug='test' args='author=2,6,17,38']

    The ‘author__in’ parameter requires an array value, so it will not work:
    $query = new WP_Query( array( 'author__in' => array( 2, 6 ) ) );

    For your case, I used the “p” parameter from here: http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

    You should be able to use anything that takes a string for it’s value.

    Hope that helps!

    Let me know if you have any more questions,
    Jonathan

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Just to follow up with some more explanation.

    The {{post:ID}} I had you use is a “contextual token”. Meaning it’s value is derived from the context in which it is used. They are perfect for dynamically altering a query based on where it is displayed.

    But you can also use explicit values if you don’t need the query to be contextually dynamic. For example, in the above “author=1,2,17” example, those values are not contextual, and will alter the query the same way no matter where it is shown.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Current post ID filter?’ is closed to new replies.