Forum Replies Created
-
AuthorPosts
-
phantomowl10
ParticipantPerfect – thanks for the quick reply.
phantomowl10
ParticipantYes, please go ahead and close the ticket – thanks!
phantomowl10
ParticipantThat’s perfect – thanks for your help.
phantomowl10
ParticipantThis 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;
}phantomowl10
ParticipantIts 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
phantomowl10
ParticipantHi 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.
phantomowl10
ParticipantHi 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 -
AuthorPosts