• Resolved brambil

    (@brambil)


    Hi.

    I would like to insert a widget with the last inserted events. The idea is to select only future events in the next X monthes and order them by event_id

    I look the documentation https://wp-events-plugin.com/tutorials/create-your-own-event-scope/ and I add some new scope, but with orderby something is wrong… Anyone can help me?

    add_filter( 'em_events_build_sql_conditions', 'my_em_orderby_options',1,2);
    function my_em_orderby_options($conditions, $args){
        if( !empty($args['orderby']) && $args['orderby']=='ultimi-inseriti' ){
           $conditions['orderby'] = " event_id " ;
        }
        return $conditions;
    }
    
    add_filter( 'em_orderby_options','my_em_orderby_options',1,1);
    function my_em_orderby_options($order){
        $my_order = array(
            'ultimi-inseriti' => 'Ultimi inserimenti'
        );
        return $order + $my_order;
    }

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter brambil

    (@brambil)

    The previous code had a PHP problem,
    this is mine code:

    //Aggiungo filtro ultimi inseriti
    add_filter( 'em_events_build_sql_conditions', 'my_em_orderby_options_add',1,2);
    function my_em_orderby_options_add($conditions, $args){
        if( !empty($args['orderby']) && $args['orderby']=='event-id' ){
           $conditions['orderby'] = 'event_id' ;
        }
        return $conditions;
    }
    
    add_filter( 'em_orderby_options','my_em_orderby_options',1,1);
    function my_em_orderby_options($order){
        $my_order = array(
            'event-id' => 'Inserimento'
        );
        return $order + $my_order;
    }
    

    It simply doesn’t work.

    If I add ‘event_id’ => __(‘ID Evento’,’events-manager’), to $this->em_orderby_options = apply_filters(’em_settings_events_default_orderby_ddm’, array( in em-events.php I get what I want…

    HELP.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try to use text widget and then install wp plugin to allow shortcode on text widgets and use short [events_list limit=”10″ pagination=1 order=”DESC” orderby=”event_id”]

    https://wp-events-plugin.com/documentation/shortcodes/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Last inserted events – Order by ‘event_id’’ is closed to new replies.