• Thank you for such wonderful plugin. Just wondering if you could help me with something. I need to limit the search results to children of a specific array of pages. I normally use ‘post_parent__in’ for normal WP queries, but I have no idea how can I implement that with your plugin.

    I saw a separate post in which it was mentioned to setup a filter on the functions file but I’m not sure how to do that either. If you could point me in the right direction or even provide me with some example code that’d be amazing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ajay

    (@ajay)

    What’s the code that you use with post_parent__in ?

    It’s a bit more difficult to do with the plugin this way.

    You can add a function using add_filter on bsearch_posts_where

    This would need to detect the post of the parent and pass that ID.

    See some examples of filter functions at: https://gist.github.com/ajaydsouza/767215093a24bafb903a

    Thread Starter fernet_con_cola

    (@fernet_con_cola)

    Hi Ajay,

    Thanks for you reply.

    I need to only query posts from a specific array of parents. This is how my normal WP query looks like:

    $post_ids = array( 14,46,67 );
    $query->set( ‘post_parent__in’, $post_ids );
    $query->set( ‘post_status’, ‘publish’ );

    I had a look at the filters which are very handy but still can’t figure out how to get around setting up what I need 🙁

    Plugin Author Ajay

    (@ajay)

    Where are you putting this code and is that the complete code or more of it?

    You could potentially replace $post_ids with this code to get the search results.

    
    $search_query = get_bsearch_query();
    $matches = get_bsearch_matches( $search_query, 0 );		// Fetch the search results for the search term stored in $search_query
    $searches = $matches[0];		// 0 index contains the search results always
    if ( $searches ) {
    	$post_ids = wp_list_pluck( $searches, 'ID' );
    }
    
    
    • This reply was modified 6 years, 2 months ago by Ajay.
    • This reply was modified 6 years, 2 months ago by Ajay.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit searches using post_parent__in’ is closed to new replies.