Skip to content

Instantly share code, notes, and snippets.

@robincornett
Last active April 29, 2019 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robincornett/1d89b99b4c3c0c94829e to your computer and use it in GitHub Desktop.
Save robincornett/1d89b99b4c3c0c94829e to your computer and use it in GitHub Desktop.
Modify the "no content matched your criteria" message in Genesis
<?php
// do not include the opening tag
add_filter( 'genesis_noposts_text', 'leaven_change_search_text_one', 10, 2 );
function leaven_change_search_text_one( $text ) {
$text .= __( ' Would you like to try again?', 'leaven' );
$text .= get_search_form( false );
return $text;
}
add_filter( 'genesis_noposts_text', 'leaven_change_search_text_two', 10, 2 );
function leaven_change_search_text_two( $text ) {
$text = __( 'This is completely embarrassing. I have no posts to show you. Care to search again?', 'leaven' );
$text .= get_search_form( false );
return $text;
}
add_filter( 'genesis_noposts_text', 'leaven_change_search_text_three', 10, 2 );
function leaven_change_search_text_three( $text ) {
if ( is_search() ) {
$text = __( 'This is completely embarrassing. I have no posts to show you. Care to search again?', 'leaven' );
} elseif ( is_archive() ) {
$text = __( 'Evidently I don\'t have much to say on this topic. Maybe you\'d like to search for something else.', 'leaven' );
}
$text .= get_search_form( false );
return $text;
}
@sitealacarte
Copy link

Very helpful, thank you!

@alexgarciab
Copy link

Is there a way to insert a heading on the page, apart from the modified text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment