• Resolved Sumukha

    (@sumukha)


    I have been reading some things in the Codex, but am not so php savy…

    I have a sidebar link
    <?php wp_list_categories(‘show_count=1&title_li=<h2>Categories</h2>’); ?>
    that needs to exclude one category.
    I see in the Codex
    query_posts(‘cat=-3’);

    How do I combine these?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Open wp-includes/widgets.php file at your local and edit it..you need to do it as these:

    Find this line:
    $d = $options[$number][‘dropdown’] ? ‘1’ : ‘0’;

    Add this line below this line:
    $ex = “1,2,3”;

    1,2,3 are the categories which you would like to exclude..

    Find this line:
    $cat_args = array(‘orderby’ => ‘name’, ‘show_count’ => $c, ‘hierarchical’ => $h);

    replace with:
    $cat_args = array(‘orderby’ => ‘name’, ‘show_count’ => $c, ‘hierarchical’ => $h, ‘exclude’ => $ex );

    Save the file and upload it on the server again..you can replace the category ID with your desired one..

    Thanks,

    Shane G.

    <?php wp_list_categories('show_count=1&exclude=10&title_li=<h2>Categories</h2>'); ?>
    exclude=10, 10 being the category ID number you want to exclude

    edit-I would not recommend edit of core WP files. In addition, when you upgrade your WP installation, such edit will be written over.

    Thread Starter Sumukha

    (@sumukha)

    Thanks! (just wonder why I wasn’t notified of your post)
    Can you also tell me how to have only one category displayed on the homepage?

    Thread Starter Sumukha

    (@sumukha)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude category on sidebar’ is closed to new replies.