• Resolved Ash

    (@ashbryant)


    Hi,

    I need your help with templates. I’m building a custom theme for a client, who has requcted a “Our People” directory (the poeple who work for the company). I have used the write post (with a few mods) to get this working for them. No issues there.

    However, I need to have two different search results page templates. One will be a “standard” results page as you know and love, however I also need a custom search result page that returns the result from a search on our people, this would then look different to the standard results page.

    Any ideas on how to do this? I have looked at the codex and I’m not a great php coder so not too sure how to use the examples they give on the normal template pages/post to help me.

    I see there is “is_search()” but can you tell it that…
    if
    this is a search from this category or this category then show the results like this
    else
    show the results like this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Ash

    (@ashbryant)

    Please remember I said that I’m no php coder, but could this be along the right lines? I know it doesn’t work in this form (tried it), but getting there?

    if ( have_posts() ) { the_post(); rewind_posts(); }
    if ( in_category(14) || in_category (15) || || in_category (16) || in_category (17) || in_category (18) || in_category (19) in_category (20)) {
    include(TEMPLATEPATH . ‘/search-results-our-people.php’);
    } else {
    include(TEMPLATEPATH . ‘/search-results.php’);
    }

    Thread Starter Ash

    (@ashbryant)

    EDIT TYPOS

    if ( have_posts() ) { the_post(); rewind_posts(); }
    if ( in_category(14) || in_category (15) || in_category (16) || in_category (17) || in_category (18) || in_category (19) || in_category (20)) {
    include(TEMPLATEPATH . ‘/search-results-our-people.php’);
    } else {
    include(TEMPLATEPATH . ‘/search-results.php’);

    Thread Starter Ash

    (@ashbryant)

    Done it but I thought I would share it with you.

    if ( in_category(14) || in_category (15) || in_category (16) || in_category (17) || in_category (18) || in_category (19) || in_category (20)) {
    include(TEMPLATEPATH . ‘/search-results-our-people.php’);
    } else {
    include(TEMPLATEPATH . ‘/search-results.php’);

    removed this…
    if ( have_posts() ) { the_post(); rewind_posts(); }

    as it was causing an infanent loop!

    Can you share your exact code for this? I’m having trouble getting this to work. Any help is appreciated. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to have two different search results templates’ is closed to new replies.