• I am trying to get my front page to display formatting and images from my news posts similar to the way a single page would, when view a news item by say clicking the read more link, rather than using the excerpt.

    I replaced the_excerpt with the_content and it does display an entire post but there are no line breaks for formatting. Is this a CSS issue? a coding issue?

    In single.php, when viewing a news post such as here – https://d6960386.temp202.hostica.com/?p=28 formating works

    The codee in single.php reads as:

    <div class="post-entry">
    					<?php the_content(); ?>
    					<?php wp_link_pages('before=<span class="page-links"><strong>Pages:</strong> &after=</span>'); ?>
    				</div>

    Everything looks fine and dandy. Yet on my frontpage, which I want to display the entire the_content (entire content of a news posts) with formatting it is outputing the text of the articles with no formating

    example – https://d6960386.temp202.hostica.com/

    the code reads:

    <div class="post-entry" id="post-<?php the_ID(); ?>">
    
    					<?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { /* if post has a thumbnail */ ?>
    					<div class="news-thumb-wrapper">
    						<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
    						<div class="news-arrows"></div>
    						<h1><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    					</div>
    					<?php } else { /* if post doesn't have a thumbnail */ ?>
    					<h1 class="news-heading"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    					<?php }  ?>
    
    					<div class="news-meta-wrapper">
    						<span class="news-meta">By <?php the_author(); ?>, <?php the_time( get_option('date_format') ); ?></span>
    						<span class="news-comment"><?php comments_popup_link(__('0'), __('1'), __('%')); ?></span>
    						<span class="news-cats"><?php the_category(', ') ?></span>
    					</div>
    
    					<?php the_content(); ?>
    
    				</div>

Viewing 3 replies - 1 through 3 (of 3 total)
  • HI,

    On your single page, your p tag is receiving this style:
    .post-entry p {
    font-size: 14px;
    line-height: 20px;
    margin-bottom: 20px;

    and the front is not receiving any style for the p tag.

    Try to edit your css file to include:

    .news-wrapper p,
    .post-entry p {
    font-size: 14px;
    line-height: 20px;
    margin-bottom: 20px;

    Hit me back if you need a different solution.

    Thread Starter Kitsune86

    (@kitsune86)

    That didn’t work the examples links above are still the same I added the following to CSS file. I also found I had made some minor errors to the HTML for the show-post.php so I reverted to a default state.

    Following your advice my CSS file now includes

    /*     4.1. News     */
    	#news-wrapper { margin-bottom:24px; }
    	.news-wrapper p,{font-size: 14px; line-height: 20px; margin-bottom: 20px; }
    	.news-item { border-bottom:1px solid #DDD; margin-bottom:30px; padding-bottom:25px; }
    	.news-item p,{font-size: 14px; line-height: 20px; margin-bottom: 20px; }
    	.news-thumb-wrapper { position:relative; }

    My show-posts.php which controls the layout of the frontpage news reads

    `<div class=”news-item” id=”post-<?php the_ID(); ?>”>

    <?php if ( (function_exists(‘has_post_thumbnail’)) && (has_post_thumbnail()) ) { /* if post has a thumbnail */ ?>
    <div class=”news-thumb-wrapper”>
    <a>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_post_thumbnail(); ?></a>
    <div class=”news-arrows”></div>
    <h1><a>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></a></h1>
    </div>
    <?php } else { /* if post doesn’t have a thumbnail */ ?>
    <h1 class=”news-heading”><a>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></a></h1>
    <?php } ?>

    <div class=”news-meta-wrapper”>
    <span class=”news-meta”>By <?php the_author(); ?>, <?php the_time( get_option(‘date_format’) ); ?></span>
    <span class=”news-comment”><?php comments_popup_link(__(‘0’), __(‘1’), __(‘%’)); ?></span>
    <span class=”news-cats”><?php the_category(‘, ‘) ?></span>
    </div>

    <?php the_content(); ?>

    </div>`

    I had the opening div class wrong so I fixed it. Other than that I’ve followed your instructions as you can see on my frontpage located – https://d6960386.temp202.hostica.com/ – the text is still a jumbled mess with no formatting

    HI Kitsune86,

    Sorry it has taken me this long to reply (caught a cold). It looks like your issue was resolved, do you feel that it has?

    I see that you matched the styles between your single post content and your home page post content. Your categories are receiving the same post class as the front page, so everything looks consistent.

    One thing I noticed, it doesn’t look like your single pages are receiving a post id, like you have going on for your front and category pages. No big deal, just might be something to add if you want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Frontpage & The_Content() Not Displaying Formatting’ is closed to new replies.