Custom WP search not looking at page tags
-
So, i created a custom search using WP_Query and it is working as i need it to except for the fact that it does not seem to be searching in page tags (i have a custom plugin that allows me to add tags to pages which i implemented specifically for the search function).
Essentially i created a new instance of the WP_Query class in a new file (php) in my theme’s default folder and am calling this php file in the default “search.php” file which renders the search results.
<?php load_template(TEMPLATEPATH . '/internal-search.php'); ?>The following is the code i am using in the new custom php file (internal-search.php)
<header call="page=header"> <h1><?php _e( 'Categories Found For', 'locale' ); ?>: "<?php the_search_query(); ?>"</h1> </header> <?php // the query $the_query = new WP_Query( array( 'post_type' => 'page' , 'post_status' => 'publish' , 'post_parent' => 83 , 's' => get_search_query() ) ); ?> <?php if ( $the_query->have_posts() ) : ?> <!-- the loop --> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php the_title( sprintf( '<h2 class="title-post entry-title"><a href="%s" rel="bookmark noopener noreferrer" target="_blank">', esc_url( get_permalink() ) ), '</a></h2>' ); ?> <?php endwhile; ?> <!-- end of the loop --> <?php wp_reset_postdata(); ?> <?php else : ?> <p><?php _e( 'Sorry, no categories matched your criteria.' ); ?></p> <?php endif; ?>This might be a stupid question or something i am missing in the code, but how can i modify this search to also output results based on the query keyword matching the tags of the different pages?
Thanks
The topic ‘Custom WP search not looking at page tags’ is closed to new replies.