Forums Forums Search & Filter Pro Display result 'custom' and 'slug'

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #112247

    Hi,

    It’s possible to use ‘slug’ instead of ‘id’ in ‘display result custom’ ? (As it is done in shortcode slug)

    Something like this:

    $args = array(‘post_type’ => ‘post’);
    $args[‘search_filter_slug’] = ‘name’;
    $query = new WP_Query($args);

    Ross Moderator
    #112248

    Hey Jose

    Currently its not an option like that.

    However, you could use native WP functions to look the ID based on slug:

    https://wordpress.stackexchange.com/questions/210639/how-to-get-custom-post-type-post-id-from-slug

    The post type for our search forms is search-filter-widget 🙂

    Best

    Ross Moderator
    #112255

    Actually this may not work depending on how you are entering slug…

    This I think is dependant on your display results method..

    If you goto screen options in the search form, and make sure you view the slug, this is the slug can work in the above example I think.. I haven’t actually tried the above code yet though.

    Best

    Anonymous
    #112262

    Works fine:

    if ( $sf_post = get_page_by_path( 'my_sf_form', OBJECT, 'search-filter-widget' ) )
        $sf_id = $sf_post->ID;
    else
        $sf_id = 0;
    
    // args
    $args = array(
    	'posts_per_page' => -1,	
    	'post_type' => 'my_cpt',
    );
    
    $args['search_filter_id'] = $sf_id;
    
    // query
    $the_query = new WP_Query( $args );
    Ross Moderator
    #112471

    Good stuff 🙂 Closing this ticket.

    Best

Viewing 5 posts - 1 through 5 (of 5 total)