• Hi Greg, is it any way to show ads in list [adverts_list] sorted not by date of publishing, but randomly? (like in sidebar Adverts Widget)

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

    (@gwin)

    Hi,
    we do not have such a feature in WPAdverts by default, but you can add the code below in your theme functions.php file

    
    add_filter( "adverts_list_query", function( $args, $params ) {
        if( isset( $params["order_by"] ) && $params["order_by"] == "rand" ) {
            $args["orderby"] = array( "rand" => "DESC" );
        }
        return $args;
    }, 10, 2 );
    

    this will add a new sorting option to [adverts_list] so then to “sort” ads randomly you could use the [adverts_list] shortcode as

    
    [adverts_list order_by="rand"]
    
    Thread Starter vasian4515

    (@vasian4515)

    It works, Thanks!

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

The topic ‘Random ads order’ is closed to new replies.