I have a (I think) rather unique issue.
I would like to append a custom query string to a standard WP search query.
On my client's site, we have a section called Beautyscopes that is powered by an in-house plugin that generates the page content. Unfortunately, when this plugin was first created around 10 years ago, all data elements were created in the wp-options table, as opposed to being put into the standard wp-posts table. (I did not write the plugin myself, but as webmaster and site co-founder, I have maintained it for many years)
As a result, any standard search will not return results from that table, since wp-options is not queried as part of a standard search. And this hurts the site's SEO to a decent extent.
What I am basically trying to do is:
1) create a custom query using a string variable
2) append that string variable to the standard WP search query
Here is the standard search WP query that is currently used on the site:
$page_query = new WP_Query("s=$s&paged=$paged&showposts=10&orderby=date");
And the standard code after:
if ($page_query->have_posts()) :
$wp_query= null; $wp_query = clone $page_query;
?>
<?php $postCount=0; ?>
<?php while (have_posts()) : the_post();?>
<?php $postCount++;?>
<div class="entry">
<blah blah blah>
And here is the query I would like to append to the search query:
$scopes = new WP_Query("SELECT * FROM
wp_optionsWHERE
option_nameLIKE '%bscopes%'");
I am using the %% operator since each option name has a unique ID as follows:
bscopes_2007_09 (for Sep 2007)
bscopes_2007_10 (for Oct 2007)
and so on. So therefore, i cannot use a strict matching query. However, this is suitable for what I am trying to do.
Now, if I append the $scopes variable to the search query as follows:
$page_query = new WP_Query("s=$s&paged=$paged&showposts=10&orderby=date&scopes=$scopes");
it unsurprisingly white screens all code after that line is encountered.
Maybe I am being dense, but I am not seeing how to seamlessly append that $scopes query to the search query anywhere and am rather stuck.
Any advice is appreciated.