Custom filter to events page

Home Forums Calendar Products Events Calendar PRO Custom filter to events page

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1250350
    Aaron
    Participant

    Hello ,

    I would like to add Zip code filter to events page : http://freshatx.wpengine.com/events/

    I would like to add filter of Venue Zip codes list in this filter.

    I have add the following code to my theme functions file, filter display fine at admin end as well as in front end as you can see in the above URL.

    But this is not returning results, please let me know how can I set function setup_query_args() arguments so that it will return correct results.

    Following is my code :

    //Add zIP Filters to events page
    class TribeEventsFilter_ZipCode extends TribeEventsFilter {
    public $type = ‘select’;

    public function get_admin_form() {
    $title = $this->get_title_field();
    $type = $this->get_type_field();
    return $title.$type;
    }

    protected function get_type_field() {
    $name = $this->get_admin_field_name(‘type’);
    $field = sprintf( __( ‘Type: %s %s’, ‘tribe-events-filter-view’ ),
    sprintf( ‘<label><input type=”radio” name=”%s” value=”select” %s /> %s</label>’,
    $name,
    checked( $this->type, ‘select’, false ),
    __( ‘Dropdown’, ‘tribe-events-filter-view’ )
    ),
    sprintf( ‘<label><input type=”radio” name=”%s” value=”checkbox” %s /> %s</label>’,
    $name,
    checked( $this->type, ‘checkbox’, false ),
    __( ‘Checkboxes’, ‘tribe-events-filter-view’ )
    )
    );
    return ‘<div class=”tribe_events_active_filter_type_options”>’.$field.'</div>’;
    }

    // function to grab all possible meta values of the chosen meta key.
    protected function get_values() {

    $posts = get_posts(
    array(
    ‘post_type’ => ‘tribe_venue’,
    ‘meta_key’ => ‘_VenueZip’,
    ‘posts_per_page’ => -1,
    )
    );

    $meta_values = array();

    foreach( $posts as $post ) {

    $meta_value = get_post_meta( $post->ID, ‘_VenueZip’, true );
    if($meta_value !=”){
    $meta_values[] = array(
    ‘name’ => $meta_value,
    ‘value’ => $meta_value,

    );
    }
    }

    return $meta_values;

    }
    protected function setup_query_args() {

    $this->queryArgs = array(

    ‘post_type’ => ‘tribe_events’,
    ‘meta_key’ => ‘_VenueZip’,
    ‘meta_value’ => ‘value’,
    ‘meta_value_num’ => $this->currentValue,
    ‘meta_compare’ => ‘LIKE’,
    );
    }

    }
    // This adds our new filter to the Filterbar options
    // Invokes TribeEventsFilter::__construct($name, $slug);
    function ZipCode_taxfilter(){
    new TribeEventsFilter_ZipCode(‘ZipCode’, ‘zipcode’);
    }
    add_action(‘tribe_events_filters_create_filters’,’ZipCode_taxfilter’);

    Thanks.

    #1250608
    George
    Participant

    Hey Aaron,

    Thanks for reaching out.

    We are unfortunately not able to help with modifying the look or behavior of our plugins, as described here: lhttps://theeventscalendar.com/knowledgebase/what-support-is-provided-for-license-holders/

    To get the custom code you posted here working as you desire, you will have to continue to debug and troubleshoot your code on your own. You could also hire a professional developer to do it for you. We have a list of great developers here → http://m.tri.be/18k1 (and have no affiliation with any of these folks—they’re simply some well-respected names in the community that we’ve compiled to share in situations like this one).

    Best of luck with your custom coding. Open a new thread any time if other issues or questions that fall within the scope of customer support arise.

    — George

    #1261504
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Custom filter to events page’ is closed to new replies.