• Resolved jencoleman111

    (@jencoleman111)


    I have several categories that I do not want to display with the other categories, how can I do this
    horsemansnews.com

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    I am not exactly sure what do you mean or how should this work exactly?

    Thread Starter jencoleman111

    (@jencoleman111)

    under my classified ads, there is a category that I want to exclude. Is there a way to do that?

    Plugin Author Greg Winiarski

    (@gwin)

    If this is on the [adverts_list] you can exclude a category by adding the code below to your theme functions.php file

    
    add_filter( "adverts_list_query", "exclude_category");
    function exclude_category( $args ) {
        if( ! is_array( $args["tax_query"] ) ) {
            $args["tax_query"] = array();
        }
        $args["tax_query"][] = array(
            'taxonomy' => 'advert_category',
            'field'    => 'term_id',
            'terms'    => array( 1000 ),
            'operator' => 'NOT IN'
        );
        return $args;
    }
    

    just replace 1000 with actual ID of a category you want to exclude.

    very helfull, how do i hide also those categories in widget?

    Plugin Author Greg Winiarski

    (@gwin)

    Unfortunately, the widget does not have any filters, the only way to edit the list of categories there would be to open a file wpadverts/includes/class-widget-categories.php and modify the widget() function (most likely you will want to change params passed to get_terms function).

    Note that if you will update WPAdverts the changes in this file will be overwritten, so it would be best to copy this code and use it to create your own custom categories widget.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘need to only display certain categories’ is closed to new replies.