Support » Fixing WordPress » Creating a Custom Search Results Page?

  • Resolved WPChina


    I have searched far and wide for the answer to this question.

    I need to customize my search results page based on certain search terms.

    For example, if s=Apple, I need to place a certain image at the top of the results.

    If s=Orange, I need to include some text and a PHP include.

    Is there simple code to place within the Loop to do this? Or can I do it outside the Loop and base it on the search term?


Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi


    Forum Moderator

    I’ve not tested this but what about:

    if( trim( wp_specialchars($s,1) ) == 'Apple' ) :?>
    	[ add image markup here ]
    <?php elseif( trim( wp_specialchars($s,1) ) == 'Orange' ) :?>
    	[ add text with markup here ]
    	<?php include ('somefile.php');

    just before the Loop in search.php?



    @esmi: Excellent 🙂 it works!
    Many thanks and I hope to return the favor to you soon for support!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Creating a Custom Search Results Page?’ is closed to new replies.