• Resolved fabiano1987

    (@fabiano1987)


    I don’t know if is possible to do these 2 things but , if yes, it will be AWESOME

    1) It’s possible to exclude a category from [adverts_list]?
    At the moment i can use category=”id” to show only the ads in that category but if i want to show all the ads except for 1 category? i tried to write multiple times category=”id” with all my categories but it work only with the latest one, not all the cats i write

    2) It’s possible to add a parameter that changes the default thumbnail size?

    In the CORE > Options , i’ve setted Adverts List thumb size and “Upload Thumbnail” size

    Now, in the home page i want to use 2 [adverts_list]. The first, have to show all the categories except one with the default adverts list thumbnail size and the second have to show just 1 category (the excluded one) with the “upload thumbnail” size (named: adverts-upload-thumbnail)

    It would be awesome to have both the things as a shortcode parameter like exclude=”ID” and thumbnail=”xxx”

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

    (@gwin)

    1. out-of-box WPAdverts does not have a feature which would allow excluding the categories, but you can add the code below in your theme functions.php file

    
    add_filter( 'shortcode_atts_adverts_list', 'my_adverts_list_category_exclude_atts', 10, 3 );
    function my_adverts_list_category_exclude_atts( $out, $pairs, $atts ) {
        if( ! isset( $atts["_category_exclude"] ) ) {
            $atts["_category_exclude"] = null;
        }
        
        $out["_category_exclude"] = $atts["_category_exclude"];
        return $out;
    }
    add_filter( "adverts_list_query", "my_adverts_list_category_exclude", 10, 2 );
    function my_adverts_list_category_exclude( $args, $params ) {
        if( isset( $params["_category_exclude"] ) ) {
            if( ! isset( $args["taxonomy"] ) || ! is_array( $args["taxonomy"] ) ) {
                $args["tax_query"] = array();
            }
            $args["tax_query"][] = array(
                'taxonomy' => 'advert_category',
                'field'    => 'term_id',
                'terms'    => $params["_category_exclude"],
                'operator' => 'NOT IN',
    	    );
        }
        return $args;
    }
    

    Then you could use the [adverts_list] with _category_exclude param like this

    
    [adverts_list _category_exclude="100"]
    

    Then the Ads assigned to the category with ID 100 will not be shown on the list.

    2. i am not sure what you are asking about but if you would like to use 2 different image sizes for the thumbnails then this is not possible.

    Thread Starter fabiano1987

    (@fabiano1987)

    1. Thank you, worked

    2. Ok, i will think at something else

    your help is very precious
    this plugin is the best thing i’ve ever purchased (the addons)

    Plugin Author Greg Winiarski

    (@gwin)

    Ok great, i am glad you are liking the plugin so far 🙂

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

The topic ‘Create new shortcode parameters for [adverts_list]’ is closed to new replies.