I have changed my website's homepage to show only latest posts on the home page by going to settings > reading and using the "Latest Posts" option, but I just can't get things to work properly.
On the homepage, the entire content of a post is displayed instead of just its title and summary and this doesn't just happen on the homepage, it happens on category pages, archive pages all render this way.
My website is popularitybar.com , I'm using a mobile theme to test run things at the moment.
These are the contents of my theme's index.php file
<?php get_header(); ?>
<div id="content" class="clearfix">
<div class="container">
<?php // the loop ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- BEGIN POST FORMAT BACKGROUND CUSTOM FIELD -->
<?php $postformatbackground = get_post_meta($post->ID, 'PostFormatBackground', true); ?>
<div style="background-image: url(<?php echo $postformatbackground; ?>);background-size:100% auto;position:absolute !important;z-index:-1;top:0;bottom:0;left:0;right:0;width:100%:height:100%;opacity:.4;"></div>
<!-- END POST FORMAT BACKGROUND CUSTOM FIELD -->
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<!-- BEGIN CUSTOM FIELD FOR EMBEDDABLE CONTENT -->
<?php $featuredembed = get_post_meta($post->ID, 'FeaturedEmbed', true); ?>
<div class="video-container"><?php echo $featuredembed; ?></div>
<!-- END CUSTOM FIELD FOR EMBEDDABLE CONTENT -->
<!-- BEGIN SHORTCODE OUTSIDE THE LOOP -->
<?php $shortcode = get_post_meta($post->ID, 'Shortcode', true); ?><?php echo do_shortcode($shortcode); ?>
<!-- END SHORTCODE OUTSIDE THE LOOP -->
<!-- BEGIN COMMENT COUNT + TAG DISPLAY -->
<div class="comment-tag-wrapper">
<a href="<?php the_permalink(); ?>#respond"><?php comments_number( '<span class="no-comments">'.__('no comments', 'hero').'</span>', '<span class="has-comments">1 '.__('comment', 'hero').'</span>', '<span class="has-comments">% '.__('comments', 'hero').'</span>' ); ?></a>
<?php the_tags('<span class="post-tag">','</span><span class="post-tag">','</span>'); ?>
</div>
<!-- END COMMENT COUNT + TAG DISPLAY -->
<!-- BEGIN TITLE, CONTENT -->
<h1 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="entry-content"><?php the_content( __( 'Continues..', 'hero' ) ); ?></div>
<!-- BEGIN TITLE, CONTENT -->
</article>
<div class="index-separator"></div>
<?php endwhile; ?>
<!-- BEGIN NEXT PAGE, PREV PAGE -->
<?php get_template_part( 'includes/pagination'); ?>
<!-- BEGIN NEXT PAGE, PREV PAGE -->
<?php else : ?>
<!-- BEGIN NO CONTENT FOUND -->
<p><?php _e( 'Sorry, nothing found.', 'hero' ); ?></p>
<!-- END NO CONTENT FOUND -->
<?php endif; ?>
</div>
<!-- /#content -->
<?php get_footer(); ?>
Thanks!
<div class="entry-content"><?php the_content( __( 'Continues..', 'hero' ) ); ?></div>
with<div class="entry-content"><?php the_excerpt(); ?></div>
. You will have draw backs asthe_excerpt()
strip out all htmls tags before it is returned, but again, there are ways to overcome that by creating a custom excerpt function.the_excerpt();
function earlier but the posts still show up with the entire content, I only want the title, featured image and a brief summary of the post with the "continues" permalink of the full post. How do I go about creating a custom excerpt function?