WordPress.org

Support

Support » Plugins and Hacks » Search every page option missing – can't search pages

Search every page option missing – can't search pages

  • devra
    Participant

    @devra

    I just installed Search Everything 6.9 with WordPress 3.5.1. I need to be able to search page content.

    In the Settings area, there is no option to search pages. I see the option on the screen prints for the plugin, but don’t have it on my site.

    I have created my own theme, so tried activating twentyeleven and twentytwelve. Still no option.

    Any help would be greatly appreciated.

    http://wordpress.org/extend/plugins/search-everything/

Viewing 14 replies - 1 through 14 (of 14 total)
  • devra
    Participant

    @devra

    Does anyone have Search Everything running on WordPress 3.5.1, and also have the option to search pages?

    Thanks.

    v_decadence
    Member

    @v_decadence

    The same issue for me – WordPress 3.5.1 and Search Everything 6.9.4.1. There are no page options on plugin settings page. But anyway search works for pages. I tried it on the two different sites.

    devra
    Participant

    @devra

    It does not search pages for me. I am just using the standard WordPress search widget. I have even added the following code to functions.php, which I found in the forums:

    /* 	2/26/13 - Try adding pages to search function.
     According to forum helper,
    http://wordpress.org/support/topic/need-to-search-page-content?replies=2#post-3937857
    	this should be working. */
    function filter_search($query) {
        if ($query->is_search) {
        $query->set('post_type', array('page','post'));
        };
        return $query;
    };
    add_filter('pre_get_posts', 'filter_search');

    Our site is almost all pages with no posts so this is important to us.

    Please, can anyone else verify that the above code should be allowing me to search pages? I have run out of ideas and can’t find any more in the forums.

    Thanks.

    You should put this part of code

    add_filter('pre_get_posts', 'filter_search');

    into the layout template. For example, to index.php.

    if (is_search()) :
      add_filter('pre_get_posts','SearchFilter');
      get_posts();
    else :
      /* the usual way of retrieving posts */

    devra
    Participant

    @devra

    I tried putting the add_filter in the template, then in the footer. It makes no difference.

    I am at a loss.

    I am running WP 3.5.1.
    I am using the WP default search widget in the footer.
    I do not have a custom searchform.php. It comes from general-template.php.
    I do have a search.php.

    When I search, I get results for Posts but not Pages, which is what I need.

    I added this code to functions.php as well, but it had no effect.

    /* 	2/26/13 - Try adding pages to search function.
     According to forum helper,
    http://wordpress.org/support/topic/need-to-search-page-content?replies=2#post-3937857
    	this should be working. */
    function filter_search($query) {
        if ($query->is_search) {
        $query->set('post_type', array('page','post'));
        };
        return $query;
    };
    add_filter('pre_get_posts', 'filter_search');

    I tried the most recent version Search Everything plugin, but it has no option in Settings for Pages, as it is supposed to have. No response from author.

    Anyone have a suggestion of what I am doing wrong?

    What code did you put to the template?

    devra
    Participant

    @devra

    Hi, Telfia.

    I put
    add_filter('pre_get_posts', 'filter_search');

    This is the same code I have in functions.php. I removed it from functions.php as well, but that didn’t make a difference. I didn’t even make it conditional on is_search(), I just added it to the top of the page or footer.

    Any ideas?

    What function do you use for getting posts?

    devra
    Participant

    @devra

    Here is my search.php:

    <?php get_header(); ?>
    <section id="mainContent" class="cf">
    	<article id="editorial" class="cf search-results">
            <?php if (have_posts()) : ?>
        		<p class="page-title"><?php printf( __( '<span class="smallertext">Search Results for:</span> %s', 'willoughby' ),
    				'<span><strong>' . 	get_search_query() . '</strong></span>' ); ?></p>
        	<?php while (have_posts()) : the_post(); ?>
        		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
            		<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
            		<div class="entry">
                		<?php the_excerpt(); ?>
                		<div id="customcontinue"> <a href="<?php the_permalink() ?>"><span> read more...</span></a></div><!-- End of customcontinue -->
            		</div><!-- End of the excerpt -->
        		</div> <!-- End of single search result -->
         <?php endwhile; ?>
         <?php else : ?>
        		<p class="page-title"><?php printf( __( 'Sorry. No search results found for: <span class="redtype"> %s </span>', 'willoughby' ),
    				'<strong>' . get_search_query() . '</strong>' ); ?></p>
        <?php endif; ?>
        </article>
    </section><!-- End of #mainContent-->
    <?php get_footer(); ?>

    The next code works for me:

    <?php get_header(); ?>
    <section id="mainContent" class="cf">
    	<article id="editorial" class="cf search-results">
            add_filter('pre_get_posts','filter_search');
            get_posts();
            <?php if (have_posts()) : ?>
    // the rest of code

    Amazing. Now it works directly from functions.php. I removed some plugins last week. Setting the priority might be useful for you.

    function filter_search($query) {
        if ($query->is_search) {
        $query->set('post_type', array('page','post'));
        };
        return $query;
    };
    add_filter('pre_get_posts', 'filter_search', 999);
    devra
    Participant

    @devra

    Hi, Telfia. Thanks so much for sticking with me.

    This is really making me nuts. I tried the 999 value above and it had no effect. I tried playing around with get_posts() and setup_postdata. No go.

    Then I started looking at another site we have, also with a custom theme, where page content is searched. The working site has no additional functions for searching in functions.php. It uses a simple searchform and search.php. Using these in the new site, I still was not getting search results for pages.

    Then I started playing around with page content. Here is where it gets interesting. Most of our page content is not placed in the Text Editor window. It is placed in page custom fields which are then strategically placed in the page layout. Their value is echo’ed to show on the page. Content that goes directly into the page Text Editor IS found. Content that goes into custom fields which are then echo’ed onto the page is NOT found. Also, content in custom templates is not found.

    So now we have built a custom theme which uses custom fields. These allow a sophisticated page layout, and allow the user to modify page content in the custom fields. But, our page content can’t be searched.

    Any idea if there is a way to search template content and custom fields in the regular search box?

    As for me, it’s better to use plugin for such kind of search. The Search Everything plugin have options for searching custom fields and does it perfectly for my site.

    In other hand you could find usefull this discuss.

    Thanks, Telfia, for all your time. I appreciate you sticking with me trying to figure this out.

    I ended up taking all the content out of the custom fields, and putting all the html and php (using ezPHP plugin) right into the page editor window. I hadn’t wanted to do this because the user plans to update the text periodically, and I felt we would be more vulnerable to them messing up the html. But, that’s just what we’re going to live with. So now my page content is searchable.

    Thanks again.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Search every page option missing – can't search pages’ is closed to new replies.