0

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!

7
  • From what I can see is that your posts do show excerpts on the front page, not the complete post. If you changed your code after you posted your question, please update it then in your question as well Mar 2, 2014 at 5:41
  • Thanks Pieter, actually I'm in the middle of a dns propagation with my new host so what you are seeing might be content from my old host, can you please post a screenshot of how it looks like for you at your end. I don't see excerpts at all. I was able to fix the post order on my page by removing all sticky posts. Mar 2, 2014 at 13:04
  • OK, I can see full posts now on your website. Just replace the following line <div class="entry-content"><?php the_content( __( 'Continues..', 'hero' ) ); ?></div> with <div class="entry-content"><?php the_excerpt(); ?></div>. You will have draw backs as the_excerpt() strip out all htmls tags before it is returned, but again, there are ways to overcome that by creating a custom excerpt function. Mar 2, 2014 at 13:16
  • Thank you, I tried using 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? Mar 2, 2014 at 13:21
  • have you tried flushing your browser cache after you've made changes. Mar 2, 2014 at 13:29

1 Answer 1

0

I actually got this issue fixed with a very simple feature in wordpress my theme developer had never mentioned, after hours of misery and awesome help from @Pieter .

I was doing a lot of research and found out some themes required I use the <!--more--> tag built in wordpress to show only a part of my posts on the homepage. So I decided to tried inserting the more tag in one of my posts and alas! I saw an excerpt of my post from where I had placed the <!--more--> tag.

Obviously, I wasn't going to be adding more tags manually into over 2035 posts, so I created a simple plugin to insert the more tag after a specific character count using php's strlen in all my posts. I still can't believe the fix was this simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.