• Resolved mukethedude

    (@mukethedude)


    Output of an standard Archive Link of a customer post type with 3 taxonomies. How to find out the parameters of the wp_query after. (archive.php)

    Output of a single post of a customer post type . How to find out the parmeters of the query which have led to the result on the the single.php

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Install the plugin “Query Monitor”. It will help you track the queries used to render a page.

    Thread Starter mukethedude

    (@mukethedude)

    Thanks for your quick help. very usefull !

    but, how to find out the parameters via php on archive.php/single.php to add other information depending on result.

    regards muki

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    you’ll have to work backwards from the query to determine the actual call(s) to wp_query.

    Thread Starter mukethedude

    (@mukethedude)

    Thx again Steven !

    sorry i dont understand “backwards”. do u have an example ?

    i am a step further but i think its not a smart solution.

    on my archive.php i get with if/elseif statements on function is_tax() the right taxonomy of my custome post type:

    if (is_tax(‘taxonomy,’taxonomy_name’)) $taxonomy_title = ‘some_string’;

    elseif …. 4 times for 4 taxonomies

    Moderator bcworkz

    (@bcworkz)

    I think you are saying you don’t want to look at the parameters with a tool like Query Monitor, you want to get them with PHP for use in outputting related information from template code. Correct?

    The main query’s WP_Query object is generally available from global $wp_query. All the query vars used are within $wp_query->query_vars. The actual SQL used is $wp_query->request. Almost everything you would want to know about the query is likely somewhere within its properties. Examine the class’ properties in its source code to see what else is available.

    Note that secondary queries can overwrite the global $wp_query value so that it no longer represents the main query. You can confirm if this has happened with $wp_query->is_main_query().

    Thread Starter mukethedude

    (@mukethedude)

    Thanks,

    good advice to find the parameters directly in the wp_query array.

    i thought there are already some wp functions to grep them directly.

    Thanks and greetings to the supporters

    Moderator bcworkz

    (@bcworkz)

    i thought there are already some wp functions to grep them directly.

    Not literally grep-like, but there is get_query_var(). It’ll get any specific query var value from the global $wp_query object. It’s just a wrapper for $wp_query->get(). It’s about as close as we get to directly grepping something.

    Thread Starter mukethedude

    (@mukethedude)

    THANKS !

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WP Query parameter’ is closed to new replies.