• tlsceo

    (@tlsceo)


    Everyone, I am a newb at this, so please bare with me. I have limited knowledge when it comes to php, but I’m learning.

    The problem I am having is this. I have multiple categories, and some have sub-cats. What I would like to have happen is that when you go to a category page, that categories sub-cats are displayed on the sidebar.

    I am using Daiko’s text widget, with widget logic plugin to control what pages each widget is displayed on. The coding I am using is as follows.

    <?php
    
    wp_list_cats ("optioncount=$c&hierarchical=$h&sort_column=s&child_of=31");

    This works for the category 31, but what I need to do is pass the current category page id, to a variable, and use that variable in place of “31”.

    after searching I’ve found this snipet “get_query_var(‘cat’)”. Which should return the current category, but I am unsure how to use it, and what the syntax should be.

    Thanks in advance for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tlsceo

    (@tlsceo)

    Just incase anyone else can use this, here is what I did to resolve this issue.

    ‘<?php

    $current=get_query_var(‘cat’);

    wp_list_cats (“optioncount=$c&hierarchical=$h&sort_column=$s&child_of=$current”);

    ?>’

    carl-johan

    (@carl-johan)

    Great man, exactly what is was looking for!

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

The topic ‘Passing Cat ID’ is closed to new replies.