Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #677664

    I have the ‘Categories: Archive by Categories’ widget in my sidebar. Clicking ‘Select Category’ displays a scroll-able dropdown list of all categories.

    There is one category however that I want to exclude from the dropdown list so that users/readers cannot select or see any posts in that category.

    How can I do that?

    #677698

    Hi zimbo!

    Can you please show us a link that the widget is in place, so we can try debug the issue?
    We would really appreciate.

    Thanks a lot

    Best regards,
    Basilis

    #677704

    Page here.

    I want to stop DoNotShow and NewsTicker categories from appearing in the ‘Categories: Archive by Categories’ widget dropdown list in the sidebar.

    #677835

    Hey!

    Please add following code to Functions.php file in Appearance > Editor

    add_filter( 'widget_categories_args', 'avia_exclude_widget_category', 10, 1 );
    add_filter( 'widget_categories_dropdown_args', 'avia_exclude_widget_category', 10, 1 );
    function avia_exclude_widget_category( $cat_args ) {
    $cat_args['exclude'] = array('11','38');
    return $cat_args;
    }

    and replace 11 and 38 with your category IDs

    Cheers!
    Yigit

    • This reply was modified 8 years, 2 months ago by Yigit.
    #678123

    Thanks Yigit but there is an error in that code – line 3 should be
    function avia_exclude_widget_category( $cat_args ) {
    and not wpsites_… but I changed it, and it now works. :-)

    #678129

    Hi!

    Yes, i was editing the code and appearantly forgot to change it :) Thanks for the hint. I will update my post. Glad it worked for you :)

    Regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.