Forum Replies Created

Viewing 1 replies (of 1 total)
  • Not really sure if you have got your answer by now. As the post is kinda old, I should assume so.

    Whenever a wordpress page is visited on your website, some variables are used to query the database so it can generate the page content. There’s a nice way to check the variables in a particular page.

    Just add the line:
    var_dump(wp_query->query_vars);

    This will display the array of variables on that particular page so you can find out which ones you need to retrieve using something like:

    $variable = get_query_var('variable_name');

    In your particular case, to retrieve the category ID, you should use the variable called ‘cat’.

    It would look like this
    $cat = get_query_var('cat');

    After storing the category ID to your variable called ‘$cat’, just add it to your quuery. Here is the code…
    $featuredPosts1->query('cat=' . $cat .'&posts_per_page=10&meta_key=_my_key&orderby=meta_value&order=desc&paged='.$paged);

    Not sure if that’s what you were looking for, but I think it might be of some help to someone.

Viewing 1 replies (of 1 total)