Forums

Passing Cat ID (3 posts)

  1. tlsceo
    Member
    Posted 4 years ago #

    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.

  2. tlsceo
    Member
    Posted 4 years ago #

    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");

    ?>'

  3. carl-johan
    Member
    Posted 3 years ago #

    Great man, exactly what is was looking for!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.