WordPress.org

Ready to get started?Download WordPress

Forums

Custom Category Archives Page (16 posts)

  1. ElleJG
    Member
    Posted 1 year ago #

    Here's what I need to do. I've created a new category for which I'll need to have the full post showing on its category archive page. (I have excerpts showing on all other category pages)

    First question: am I right in assuming it's a custom category page I need to add to my child theme, and not an archive page? Or is it the opposite? Perhaps both?

    Next can you tell me what to add and/or subtract so that I have full posts showing on the category archive pages for cat 111?

    Thank you!

    PS: I'm using the Twenty Eleven theme.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    I think this is what you need to do.

    First, make a copy of category.php to your child theme's folder. Rename it to category-111.php.

    Then change this:

    <div id="content" role="main">
    
       <?php if ( have_posts() ) : ?>

    to this:

    <div id="content" role="main">
       <?php global $more; $more = 1; ?>
    
       <?php if ( have_posts() ) : ?>
  3. ElleJG
    Member
    Posted 1 year ago #

    Thanks.

    I wish I could say that worked, but I'm still getting the excerpt and not the full post.

  4. vtxyzzy
    Member
    Posted 1 year ago #

    Strange, it worked when I tested it.

    Time for some debugging. Please insert the following just after the 'global $more' line and report if you see it:

    <?php print_r('<p>DEBUG: In category-111.php </p>'); ?>
  5. ElleJG
    Member
    Posted 1 year ago #

    Yes, that line shows up on my site.

    I had confirmed that the new category page was working.

    I'm wondering if this is just a conflict with some other change I've made. I've made the following change to my child's content.php

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    		<?php else : ?>
    		<div class="entry-content">
    			     <?php echo get_the_post_thumbnail($page->ID, 'thumbnail','class=alignleft'); ?>
                                 <?php the_excerpt(); ?>

    Could that be the problem?

  6. vtxyzzy
    Member
    Posted 1 year ago #

    That looks to be it. Change the_excerpt() to the_content();

  7. ElleJG
    Member
    Posted 1 year ago #

    :) that will mess up my homepage where I need to have excepts and not full content.

    Is there anyway around this? Can I have both excepts on my homepage and a custom category page with full posts, or is it impossible for the two to work together?

  8. vtxyzzy
    Member
    Posted 1 year ago #

    Did you create a category-111.php file?

    EDIT: If you did, change this line:

    get_template_part( 'content', get_post_format() );

    to this:

    // get_template_part( 'content', '111' );

    Then make a copy of content.php to content-111.php and change the_excerpt() to the_content() there.

  9. ElleJG
    Member
    Posted 1 year ago #

    I did. I'm using the cat name instead of the cat ID however as the file name.

  10. vtxyzzy
    Member
    Posted 1 year ago #

    You beat me to the reply. Use the cat name for the get_template_part as well.

  11. ElleJG
    Member
    Posted 1 year ago #

    And do I still keep the revisions you suggested in your first post as well?

  12. vtxyzzy
    Member
    Posted 1 year ago #

    It won't hurt to keep that in, and may be necessary - I have not tested it without it.

  13. ElleJG
    Member
    Posted 1 year ago #

    Hmm. After making this change:

    // get_template_part( 'content', '111' );

    and creating a new content-name.php I lose everything but the header and the category description.

    I've deleted the content page and still have the problem, but when I revert back to this:

    get_template_part( 'content', get_post_format() );

    I get those excerpts again, which is better than nothing at all!

    I've done a ton of customizing, so I'm sure there is some other conflict I'm not thinking about, but I really do appreciate the time you're spending here.

  14. ElleJG
    Member
    Posted 1 year ago #

    Hmm, why isn't the code working??

  15. vtxyzzy
    Member
    Posted 1 year ago #

    Did you use the category slug instead of the name? The name may have characters that do not work well. Try using the slug or the id.

  16. ElleJG
    Member
    Posted 1 year ago #

    I doubt you're still around but I wanted to say sorry. Something came up and I had to bail asap.

    I'll have to readdress this tomorrow, but thank you so much for your help in the meantime.

Topic Closed

This topic has been closed to new replies.

About this Topic