• Resolved cboysworld

    (@cboysworld)


    Hello, In Twhenty-sixteen, I have a list of categories in the top primary menu. When a category button is clicked, all the post are shown. How can I show just an excerpt of the posts when a category button is clicked?

    Chad

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

    you can open the screen options (top right in your edit post page) and enable the ‘excerpt’

    Thread Starter cboysworld

    (@cboysworld)

    Thank you for your reply but I am looking for a way to dynamically add an excerpt of all post from a category in the content area. The widget from the screen tab is more of a specific excerpt.

    You will need to edit your theme and add some files.

    1.create a child theme
    2.copy your archive.php file from your parent theme to your child theme
    3.copy the folder ‘template-parts’ from your parent theme to your child theme
    4.rename ‘archive.php’ to ‘category-test.php’
    5.open the ‘category-test.php’ and find this line

    get_template_part( 'template-parts/content', get_post_format() );

    and change it to

    get_template_part( 'template-parts/custom-content', get_post_format() );

    6.go to your child theme ‘template-parts’ folder and copy paste the file ‘content.php’, rename it to ‘custom-content.php’
    7.edit it and find this code

    the_content( sprintf(
    				__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ),
    				get_the_title()
    			) );

    comment it like this

    /*the_content( sprintf(
    				__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ),
    				get_the_title()
    			) );
    */

    and add below it this

    the_excerpt();

    6.save : )
    7.the test part in the filename ‘category-test’ should be the category you
    want to target

    http://codex.wordpress.org/Child_Themes
    https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Excerpt’ is closed to new replies.