1

I am using Wordpress and the Genesis framework for a site. I'm using a child theme (Ayoshop - not that it matters much) for the theme. I would like to customize the search results page by removing the 'post info' area where it shows the date, author, and 'leave a comment' link, and instead show the featured image for that post. The theme is using the search.php page from the Genesis theme, so I'm not really sure how to proceed in how to customize it.

Here is the code from the Genesis theme search.php:

add_action( 'genesis_before_loop', 'genesis_do_search_title' );
/**
 * Echo the title with the search term.
 *
 * @since 1.9.0
 */
function genesis_do_search_title() {

    $title = sprintf( '<div class="archive-description"><h1 class="archive-title">%s %s</h1></div>', apply_filters( 'genesis_search_title_text', __( 'Search Results for:', 'genesis' ) ), get_search_query() );

    echo apply_filters( 'genesis_search_title_output', $title ) . "\n";

}

genesis();
Jason Lawton
  • 4,412
  • 3
  • 21
  • 20
  • If you can get the search template file (or post that in paste bin) I can help you with that – Shoeb Mirza May 09 '16 at 01:05
  • It's just the default search.php code from the main genesis theme. I'll add it to the question though. – Jason Lawton May 09 '16 at 01:06
  • This following piece of code doesn't help. You must find the main template of search results.. – Shoeb Mirza May 09 '16 at 01:14
  • Yeah that's my issue with Genesis. It doesn't really work that way, you just add or remove hooks/actions/filters to modify stuff, so that's where I'm having issues. – Jason Lawton May 09 '16 at 01:16
  • It doesn't make sense to me. Why you don't you copy the main template from the main theme to the child theme and start editing it? – Shoeb Mirza May 09 '16 at 01:17
  • 1
    That is the template from the main theme. If you don't have experience with Genesis don't worry, I know it's very different from just having a search template that you just copy from the main theme and edit, and believe me, I wish that's how Genesis worked right now. For now I'll wait around for someone who has experience with Genesis to respond. I'm also searching around and trying various things. – Jason Lawton May 09 '16 at 01:35

1 Answers1

2

It actually did matter that it was the Ayoshop theme, there was a custom filter that was added in a file called theme-tweaks.php that removed the original post info and added a custom post info, so I needed to remove that custom action.

All of the changes were done in the functions.php file.

I made sure to remove the genesis_post_info, and then removed the custom action that Ayoshop added.

remove_action( 'genesis_before_post_content', 'genesis_post_info' );
remove_action( 'genesis_before_post_content', 'ayo_post_info' );

I then added an action to add the image to the post.

add_action ( 'genesis_before_post_content', 'jl_post_info' );

function jl_post_info() 
    if ( has_post_thumbnail() ) {
        printf( '<div class="post-info">' . get_the_post_thumbnail() . '</div>');
    }
}
Jason Lawton
  • 4,412
  • 3
  • 21
  • 20