This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • in reply to: Hide keyword recommendations when no results found #28647
    phantomowl10phantomowl10
    Participant

    Perfect – thanks for the quick reply.

    in reply to: Multiple search widgets #28568
    phantomowl10phantomowl10
    Participant

    Yes, please go ahead and close the ticket – thanks!

    in reply to: Multiple search widgets #28546
    phantomowl10phantomowl10
    Participant

    That’s perfect – thanks for your help.

    in reply to: Multiple search widgets #28505
    phantomowl10phantomowl10
    Participant

    This makes sense and I’ve applied it to one parent page for parent ID 468. My question is now, how do I add multiple instances of this filter? For example, you’ll see that I’ve got the correctly-working filter set up for a client named NSPRO, parent ID 468. I’ve tested this and the search bar only returns the desired results.

    However, if I add a second instance for a client named Accompass – see below – it breaks functions.php:

    // — NSPRO —

    add_filter( ‘asp_query_args’, ‘asp_include_only_parent_ids’, 10, 2 );

    function asp_include_only_parent_ids( $args, $id ) {
    /**
    * Enter the post/cpt prent IDs here. The results will be
    * limited to objects with these parent IDs.
    */
    $ids = array(468);
    /**
    * Search instance IDs you want this code to apply on.
    */
    $search_ids = array(1);

    // ————————————————–
    // ————————————————–
    // — !! Do not change anything below this line !! —
    // ————————————————–
    if ( in_array($id, $search_ids) )
    $args[‘post_parent’] = $ids;

    return $args;
    }

    // — accompass —

    add_filter( ‘asp_query_args’, ‘asp_include_only_parent_ids’, 10, 2 );

    function asp_include_only_parent_ids( $args, $id ) {
    /**
    * Enter the post/cpt prent IDs here. The results will be
    * limited to objects with these parent IDs.
    */
    $ids = array(517);
    /**
    * Search instance IDs you want this code to apply on.
    */
    $search_ids = array(2);

    // ————————————————–
    // ————————————————–
    // — !! Do not change anything below this line !! —
    // ————————————————–
    if ( in_array($id, $search_ids) )
    $args[‘post_parent’] = $ids;

    return $args;
    }

    in reply to: Multiple search widgets #28438
    phantomowl10phantomowl10
    Participant

    Its all part of the WP install; maybe more accurately, we would need a different search form for parent pages and their child pages, not a subdirectory.

    So, for example, a search form on https://mindmgt.com/client-name/ that would only show results from its child pages:

    https://mindmgt.com/client-name/sleep/
    https://mindmgt.com/client-name/work/
    https://mindmgt.com/client-name/

    etc

    in reply to: Multiple search widgets #28381
    phantomowl10phantomowl10
    Participant

    Hi Ernest,

    Further to my note: I see how to include via tags, categories, etc but I’m looking to only include Pages from specific subdiretories.

    in reply to: Multiple search widgets #28380
    phantomowl10phantomowl10
    Participant

    Hi Ernest,

    Thanks for confirming – I see now how to duplicate the search bars.

    Question though: how do I one up to only include searches from a subdomain, i.e. /n-spro/

    Thanks,
    Cam

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