You can swap the order of the post title and thumbnail featured image of a post on an archive page by rearranging the genesis_do_post_image from its default position in the entry content into the entry header, this is done by removing and adding the function in a higher location.
In your functions.php add in
function themeprefix_swap_title_image() { if ( is_archive() || is_home() ) { remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 ); } } add_action( 'genesis_before_content', 'themeprefix_swap_title_image' );
The code is using PHP conditionals to target an archive page as well as the home blog post page, you could target specific category archive pages. The initial genesis_do_post_image action is set with a priority of 8, so it has to be removed with the same priority, it is then added in the new hook position also with that priority so the image will sit above the post title.
If you only wanted this behavior to appear just on a certain custom post type page archive you can just add some further conditional code:
// Swap image and title on CPT function themeprefix_swap_title_image_cpt() { if ( is_archive() && 'cpt-name' == get_post_type()) {//add in your CPT name remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 ); } } add_action( 'genesis_before_content', 'themeprefix_swap_title_image_cpt' );
So in the above code, only the archive page of the CPT called ‘cpt-name’ would be affected.
2 comments
Leslie
Thank YOU!!! I have been working on this for way to long. Always simpler than I think.
Sean Vandenberg
Thanks, Neil!
…All the other posts out there were leaving me with the featured image displayed BOTH before the title and after…
If anyone should be listed as a recommended Genesis developer (http://www.studiopress.com/genesis-developers) – it should be you, Sir :).
Again, thanks for all your help!
– Sean