Skip to content

Instantly share code, notes, and snippets.

@vajrasar
Created September 14, 2013 07:11
Show Gist options
  • Save vajrasar/6559551 to your computer and use it in GitHub Desktop.
Save vajrasar/6559551 to your computer and use it in GitHub Desktop.
This code gets the first image of the post (not the featured image) and places it above the Post Title and in second step it removes the first-image-of-content (the_content) from post content to remove same image showing twice (above title and in content). Code goes in functions.php
<?php
add_action('genesis_entry_header','image_above_t',7);
function image_above_t() {
?>
<div id="i_a_t" style="width: 200px; margin:0 auto;">
<?php
echo genesis_get_image();
?>
</div>
<?php
}
add_filter('the_content', 'remove_image_content');
function remove_image_content($content) {
return preg_replace("/\< *[img][^\>]*[.]*\>/i","",$content,1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment