The problem is whenever I display a post containing gallery, it shows them all on front page same as within post. I want a function for posts on front page to display only the clickable featured image with read more below for posts have predefined featured image. And if the post has some specific category eg. video, it should just display video and below some sharing buttons.
This is what I achieved till now, being a newbie can’t move further
function insertfeaturedimage($content) {
global $post;
if ( current_theme_supports( 'post-thumbnails' ) ) {
if (is_page() || is_single() || is_front_page()) {
$content = the_post_thumbnail('page-single');
$content .= $original_content;
}
}
return $content;
}
add_filter( 'the_content', 'InsertFeaturedImage' );
I want the above functionality to above function.
Any help appreciated.
I am not sure that a filter on
the_content
is the way to go here. If I understand you, I think that all you need is something like the following your theme– cribbed from the two Codex pages listed below and altered slightly.That may not look right since I don’t know what your theme code looks like but that it the idea.
If you are going to filter
the_content
I think what you want is more like this:Note: I used
get_permalink($post);
instead ofget_permalink($post->ID);
on purpose. Despite the docs,get_permalink
will accept the$post
object itself and if given the object won’t runget_post
. You can save a query (under some circumstances anyway).http://codex.wordpress.org/Function_Reference/the_post_thumbnail
http://codex.wordpress.org/Customizing_the_Read_More