Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Swap Post Title and Image Position on Archive Page in Genesis

October 9, 2014 Leave a Comment

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.

genesis-swap-title-image-archive

In your functions.php add in

function themeprefix_swap_title_image() {
     if ('is_archive') {
		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, 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.

genesis-swap-title-image-archive-after

 

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.

Cats: WordPress

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Copyright © 2023· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2023 · gee on Genesis Framework · WordPress · Log in