how to change search results in child theme using child's functions.php
-
I am using a Twenty Twelve Child theme and would like to customize the search results. In searching for the answer, all of them say to copy Twenty Twelve’s search.php into the child folder and alter it from there.
But surely there is a way to do this in the child theme’s functions.php?
I would really rather let people who actually understand coding do it and if the search.php in Twenty Twelve has to be updated for security reasons, the search.php will automatically be updated in my child theme.
This is the only part (ie: cosmetic part) of Twenty Twelve’s search.php that I would like to change:
<div class="entry-content"> <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentytwelve' ); ?></p> <?php get_search_form(); ?> </div>
I’m guessing that I could use gettext for the words, but I do not understand what the numbers are in the examples shown. I don’t know enough about coding to even know how to search for what the numbers mean.
But I would also like to remove “get_search_form();” from the results. The search form is already on the sidebar.
https://codex.www.ads-software.com/Plugin_API/Filter_Reference/gettext
Not that I know what a hook is, but is there a hook for the search results? Can I use that somehow? Something along this lines:
function display_no-result() { if ( is_search('no-result') ) { echo '<div class="entry-content"> <p><?php _e( 'There are no matches. Unfortunately, the search is quite literal. Please check your spelling and try again using the search box on the sidebar.', 'twentytwelve' ); ?></p> </div>'; } } add_action( 'twentytwelve_search-no-results-hook_if-there-is-such-a-thing', 'display_no-result');
Thank you for any help you can offer.
E Morris,
e t h e r w o r k [dot] n e t [slash] b l o g
(no link because I don’t want to suffer through a malicious bot attack again)
- The topic ‘how to change search results in child theme using child's functions.php’ is closed to new replies.