• Hi, I have just created my first WP site and this theme is perfect for me. My blog posts are fairly long and I would like to show excerpts when the category or archive buttons are activated. I now get full posts and this makes it difficult for a user to navigate around my site. I am just starting to learn about coding and I have read that changing “the_content” to “the_excerpt” will do this. But I do not know which templates to make this change to. Any help would be greatly appreciated. Other themes have this feature already, but I do not want to change themes if I don’t have to.

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

    You need to modify the archive.php file.

    Before doing that, do you have a child theme installed? Because as we need to change a template file, we have to do it in a child theme (don’t change your theme core files because you’ll lose all your changes when you update the theme).

    If you don’t, I encourage you to read the documentation about Child Theme.

    And if you do, you can go further by copying the parent archive.php file into your child theme. Then, edit the file and find this part of the code.

    <?php
         get_template_part( 'template-parts/content', get_post_format() );
    ?>

    You’ll have to replace it by :

    <?php
       $post_display_option = get_theme_mod('post_display_option','post-excerpt');
    
       if($post_display_option == 'post-excerpt'){
            get_template_part( 'template-parts/content','excerpt');
       }
    
       else{
           get_template_part( 'template-parts/content', get_post_format() );
       }
    ?>

    This previous code was taken from the index.php file (from line 32 to 49) if you want to check it out.

    I hope it will help!

    Awesome, this was just what I needed and it worked like a charm, mioudesign.
    Thanks a ton for helping out! ??

    edit: Did you manage as well, williamcg?

    Thread Starter williamcg

    (@williamcg)

    RemcoGerritsen and mioudesign,

    I had a major computer crash the day after mioudesign posted his solution. I just got everything back up and running two days ago. Whew!

    I really appreciate the feedback from both of you. I am new to this coding stuff and am currently working on understanding the Child Theme. Now that I have some direction I am looking forward to working this out.

    Thank you very much mioudesign!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to create excerpts on category/archive pages’ is closed to new replies.