Integration with Search & Filter Pro

Support MB Views Integration with Search & Filter ProResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #27520
    ClayClay
    Participant

    Hey guys,

    I'm trying to filter a view using the Search & Filter Pro plugin. It seems like this should be possible but I can't seem to get it to work.

    This is their instruction for filtering custom result:https://searchandfilter.com/documentation/search-results/custom/

    Could you point me in the right direction for doing this?

    Thanks

    #27584
    Long NguyenLong Nguyen
    Moderator

    Hi Clay,

    To use a third-party plugin in View, you can create your own function then call it via the proxy mb.function_name(). Get more details on the documentation https://docs.metabox.io/extensions/mb-views/#running-php-functions

    #27629
    ClayClay
    Participant

    Hey Long,

    I've tried that but can't get it to work. Would you mind including some sample code?

    $args = array('post_type' => 'post');
    $args['search_filter_id'] = 123;
    $query = new WP_Query($args);

    That is the code given by Search & Replace Pro to implement in a custom way.

    Any help would be greatly appreciated.

    #27647
    Long NguyenLong Nguyen
    Moderator

    Hi,

    I have not used the Search & Filter before but if you want to show the results in View, you can create a custom function in the file functions.php or Code Snippets

    function show_my_posts() {
        $args = array('post_type' => 'post');
        $args['search_filter_id'] = 123;
        $query = new WP_Query( $args );
        while ( $query->have_posts() ) {
            $query->the_post();
            echo get_the_title() . '<br>';
        }
        wp_reset_postdata();
    }

    then call it in View via proxy {{ mb.show_my_posts() }}

    #27663
    ClayClay
    Participant

    Amazing! This got me mostly there. Thanks for the code sample. Is it possible to echo the contents of the Meta Box View in that function so the results being returned and filtered are rendered by the view or would this be done with PHP in the function above?

    #27702
    Long NguyenLong Nguyen
    Moderator

    Hi,

    In the PHP code, you can use the function do_shortcode() to render the shortcode.

    echo do_shortcode('[ mbv id="12345" ]');

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.