WordPress.org

Forums

[resolved] Search pages as well as posts (8 posts)

  1. Alex Cragg
    Member
    Posted 8 years ago #

    Im using the default search widget you get with Automattic widgets, but it only searches posts not pages.

    I would use the google search plugin they offer but i can't resize it for some reason(...maybe css would work?) and it messes with my sidebar a bit.

    does anyone know how to include pages in the search as this would be the ideal solution?

  2. Samuel B
    moderator
    Posted 8 years ago #

  3. Alex Cragg
    Member
    Posted 8 years ago #

    brilliant, now displays posts and pages. wahoo.

    now...

    how do i format the results to display a title and a snipet? instead of every page one after the other for ever and ever down the page,

    thanks again

    PS, using searcheverything one by dan cameron

  4. Samuel B
    moderator
    Posted 8 years ago #

    Not sure about that one.
    I would assume something like:
    <a href="<?php the_title(); ?>"><?php the_excerpt(); ?></a>
    Play around with it?

  5. Alex Cragg
    Member
    Posted 8 years ago #

    which file should i be putting that into? and do i have to define what the_excerpt and the_title are? if so where? Found this as on another post...which im assuming would work so that if it was search results it displays excerpt, and if it was normal view it would show the content, but where should that go?

    <?php if ( is_search() ) {
    the_excerpt();
    } else {
    the_content();
    } ?>

  6. Samuel B
    moderator
    Posted 8 years ago #

    look in your theme's search.php and/or sidebar.php.

  7. randymelder
    Member
    Posted 8 years ago #

    http://www.randymelder.com/index.php/technology/modifying-wordpress-to-search-pages-too/

    I thought I'd reply with my super simple non-elegant solution.

  8. mahalie
    Member
    Posted 7 years ago #

    I would not use Randy's method, as it involved modifying the core, which will stop working when you upgrade. There are plugins that will extend search to pages.

Topic Closed

This topic has been closed to new replies.

About this Topic