I'm working on a WordPress site and the overall search on the site is pulling in my slider images. I only want it to pull from the blog and from pages. I'm using the Meta Slider plugin.

The url tells me this from one example of a slider:

page=metaslider&id=147

How can I query this dynamically in the search to bypass these items?

<?php
    global $query_string;

    $query_args = explode("&", $query_string);
    $search_query['post_type'] = array('post', 'page');

    foreach($query_args as $key => $string) {
        $query_split = explode("=", $string);
        $search_query[$query_split[0]] = urldecode($query_split[1]);
    } // foreach

    $search = new WP_Query($search_query);
?>

<div class="wrapper">
    <div class="row">
        <div class="small-12 medium-9 large-9 column"> 
            <article id="search">
                <h3 class="article-title">Search Results For: <em><?php the_search_query(); ?></em></h3>
                <?php while (have_posts()) : the_post(); ?>
                <?php include('loop.php'); ?>
                <?php endwhile; ?>
            </article>
        </div>

        <div class="small-12 medium-3 large-3 column"> 
           <aside>
              <?php get_sidebar(''); ?>
           </aside>
        </div>
    </div>
 </div>
有帮助吗?

解决方案

Try updating to the development version of Meta Slider, I've updated it so slideshows shouldn't be returned in search results. To install the development version:

  1. Go to http://wordpress.org/plugins/ml-slider/developers/
  2. Download the 'Development version' (under 'Other Versions')
  3. Log into WordPress
  4. Go to Plugins > Installed Plugins
  5. Deactivate and Delete Meta Slider (you will not lose your slides)
  6. Go to Plugins > Add New > Upload
  7. Select the development version zip file from your computer
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top