WPChina
Member
Posted 3 years ago #
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?
Tks!
I've not tested this but what about:
<?php
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');
endif;?>
just before the Loop in search.php?
WPChina
Member
Posted 3 years ago #
@esmi: Excellent :) it works!
Many thanks and I hope to return the favor to you soon for support!