WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] the_content not working, only showing excerpts

[Resolved] the_content not working, only showing excerpts

  • I’ve read up and tried everything I can to fix this but cannot figure out why it’s not working as it should:

    I’m using a child theme for twentyten and only re-did the style.css and a page template, neither of which should affect this problem, which is with a category page here:

    http://abstractionatwork.org/category/gifting-abstraction/

    This is a category page set up to display posts of the category “Gifting Abstraction” but they all appear with only excerpt, not full content. I tried to fix this in loop.php by making sure it lists the_content rather than the_excerpt for standard format posts, but that does not work.

    I read about Category Templates to find out which template would be used by this category page. The file category.php calls up the loop through

    get_template_part( ‘loop’, ‘category’ );

    which, after reading the help doc on category pages, I think means that it will call up the main loop.php file (in twentyten)

    I made sure that loop.php is set to display the_content rather than the_excerpt for the standard type posts, but it’s still displaying the “Continue reading…” after a couple lines.

    I would be very grateful if anyone can help me fix this! Thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Open and save loop.php to your child theame as loop-category.php

    Find:
    if ( is_archive() || is_search() ) :
    Change to:
    if ( is_search() ) :

    Done!

    HTH

    David

    Hi David – thanks so much! but it didn’t seem to work. Still same problem. Any other ideas? Should I name it after the category slug? Many thanks.

    Hi mjd67
    The post still has the class “entry-summary” so there is something wrong.

    Looking at the body class for your linked page:
    <body class="archive category category-gifting-abstraction category-4">
    Could it be it is not loading category.php but archive.php, to test save the loop-category.php as loop-archive.php or add the categories widget to the sidebar and test the categories page.

    There should a category.php in twenty ten, and loop-category.php from the child would normally be used, but your site is loading archive.php

    If we look at a single post we can see the file name single.php first in the body class.
    <body class="single single-post postid-131 single-format-standard">

    If we look at a search we can see the file name search.php first in the body class.
    <body class="search search-results">

    So I would say that WordPress is not loading category.php but falling through to archive.php

    Category display

    1. category-{slug}.php – If the category’s slug were news, WordPress would look for category-news.php
    2. category-{id}.php – If the category’s ID were 6, WordPress would look for category-6.php
    3. category.php
    4. archive.php
    5. index.php

    HTH

    David

    David, thank you for taking the time to help.

    I see what you mean about the source code but it does not seem to be calling archive.php. I tried what you suggested and a couple other things:

    1. I tried adding some html to archive.php (no longer there now) and it turned up properly when I clicked on archives, but did not on the page where I’m having the problem.

    2. I added the categories widget to the sidebar. It also displays only excerpts. The file category.php (in 2010 theme files) has this code for calling the posts:

    <?php
    					$category_description = category_description();
    					if ( ! empty( $category_description ) )
    						echo '<div class="archive-meta">' . $category_description . '</div>';
    
    				/* Run the loop for the category page to output the posts.
    				 * If you want to overload this in a child theme then include a file
    				 * called loop-category.php and that will be used instead.
    				 */
    				get_template_part( 'loop', 'category' );
    				?>

    3. I also tried your suggestion of duplicating loop-archive and renaming it loop-category and putting it in both the 2010 folder and then later in the child theme folder, but neither changed anything.

    I really don’t get what’s happening. If you have any more ideas please let me know, and thanks again.

    mjd

    Ok,
    Parent Theme’s loop.php save as loop-category.php in the child theme’s folder, and remove all the code for the excerpt.

    The loop-category.php is working and coming up as is_archive(), so you can just change, if ( is_archive() || is_search() ) to just if ( is_search() ) I have tested this and that will work.

    Or find:

    <?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    <?php else : ?>
    	<div class="entry-content">
    		<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>
    	</div><!-- .entry-content -->
    <?php endif; ?>

    Remove the excerpt part and condition so you have just.

    <div class="entry-content">
    	<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>
    </div><!-- .entry-content -->

    HTH

    David

    I have tested this in a twenty ten child and it is working as expected with a loop-category.php, so the ‘dumb question’ are you using the more option from the editor in the posts or auto excerpts?

    If a post has the inserted <!--more--> tag in the post then it will always show as Continue Reading until you open the full post.

    HTH

    David

    Thank you David! That worked (the 2nd way you suggested – for some reason not the first). I really appreciate your help!

    mjd

    and BTW it wasn’t the “more” option. I’ve made equally dumb mistakes before but not this time.

    Thank you also Oleg – I read through that thread and couldn’t find anything to help with this particular problem but thank you for the pointer as that was useful too.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] the_content not working, only showing excerpts’ is closed to new replies.
Skip to toolbar