Support » Fixing WordPress » How to show excerpts on home page in WordPress (using Twenty

Viewing 13 replies - 1 through 13 (of 13 total)
  • neotechnomad

    (@neotechnomad)

    Actually, you shouldn’t change theme any files, because when the main theme updates, all the changes you may have made to the main theme will be lost.
    You really should be creating a Child Theme for any changes.

    That site should have know better than to show people how to change the theme files.

    So, the process is:
    Create the Child Theme as above link.
    Upload to “wp-content > themes”.

    Next…
    Download copy of content.php to your computer
    Open it in a plain text editor such as Notepad or Notepad++ (Windows) and the top you will see this:

    /**
     * The template part for displaying content
     *
     * @package WordPress
     * @subpackage Twenty_Sixteen
     * @since Twenty Sixteen 1.0
     */

    Change both instances of Twenty_Sixteen to your child theme name. Save.
    Upload into Child Theme folder on site.

    Go to Appearance > Themes in your site’s Dashboard and activate the Child Theme.
    Go to Appearance > Editor, select the content.php in the child theme (on the right of the window). Make your changes and update the file.
    View your changes.

    lanigiro

    (@lanigiro)

    Hi NeoTechnomad,
    Thank you for your response to the question.
    I only need to change both instances of Twenty_Sixteen to my child theme name im right? I dont need to follow the instructions on that site.
    Cheers!

    neotechnomad

    (@neotechnomad)

    No…
    After creating the child theme (which you will name twentysixteen-child) as per the above link:
    – the stye.css
    – the functions.php

    <?php
    
    function theme_enqueue_styles() {
    
        $parent_style = 'twentysixteen';
    
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'twentysixteen-child',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style )
        );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

    Insert the above code into the child theme functions.php file exactly as it is AND nothing else in the file AND no space underneath the last line of code AND no closing tag “?>“.

    Upload to “wp-content > themes”.

    Next…
    Download a copy of content.php from the Twenty Sixteen theme to your computer
    Open it in a plain text editor such as Notepad or Notepad++ (Windows) and at the top you will see this:

    /**
     * The template part for displaying content
     *
     * @package WordPress
     * @subpackage Twenty_Sixteen
     * @since Twenty Sixteen 1.0
     */

    Change it to this:

    /**
     * The template part for displaying content
     *
     * @package WordPress
     * @subpackage Twenty_Sixteen-Child
     * @since Twenty Sixteen Child 1.0
     */

    Save.
    Upload into Child Theme folder (twentysixteen-child) on site.

    Go to Appearance > Themes in your site’s Dashboard and activate the Child Theme.
    Go to Appearance > Editor, select the content.php in the child theme (on the right of the window). Make your changes to the Child Theme’s content.php as per the instructions on that site and update the file.
    View your changes.

    lanigiro

    (@lanigiro)

    Everything I have done is correct. Nothing happens. I tried new method: http://johngirdwood.com/2015/12/21/show-excerpt-snippets-on-blog-for-wordpress-twenty-sixteen-theme/ but it show only title the text snippet is hidden.

    neotechnomad

    (@neotechnomad)

    Here’s the problem. In the code from the site, the top line is:
    if ( is_single() ) :
    Change that to:
    if ( is_home() ) :

    lanigiro

    (@lanigiro)

    Thank you for all your help.
    I know that, but if i change “is_home or is_search” nothing happens, i tried all of them.

    neotechnomad

    (@neotechnomad)

    If you are using a Static Front Page, then the change would be:

    if ( is_home() || is_front_page() ) :

    lanigiro

    (@lanigiro)

    Unfortunately, and this suggestion has no effect.
    Cheers!

    neotechnomad

    (@neotechnomad)

    Are you putting this inside the Loop?

    neotechnomad

    (@neotechnomad)

    Forget the above question… try:

    <div class="entry-content">
    		<?php
    		if ( is_single() ) :
    			/* translators: %s: Name of current post */
    			the_content( sprintf(
    				__( 'Continue reading %s', 'twentysixteen' ),
    				the_title( '<span class="screen-reader-text">', '</span>', false )
    			) );
    
    			wp_link_pages( array(
    				'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentysixteen' ) . '</span>',
    				'after'       => '</div>',
    				'link_before' => '<span>',
    				'link_after'  => '</span>',
    				'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>%',
    				'separator'   => '<span class="screen-reader-text">, </span>',
    			) );
    
    			else if ( is_home() || is_front_page() ) :
    
    			/* translators: %s: Name of current post */
    			the_excerpt( sprintf(
    				__( 'Continue reading %s', 'twentysixteen' ),
    				the_title( '<span class="screen-reader-text">', '</span>', false )
    			) );
    
    			wp_link_pages( array(
    				'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentysixteen' ) . '</span>',
    				'after'       => '</div>',
    				'link_before' => '<span>',
    				'link_after'  => '</span>',
    				'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>%',
    				'separator'   => '<span class="screen-reader-text">, </span>',
    			) );
    			endif;
    		?>
    	</div><!-- .entry-content -->
    lanigiro

    (@lanigiro)

    NeoTechnomad, Thank you for your time, patience, and persistence. I am trying all, but nothing have an affect.

    neotechnomad

    (@neotechnomad)

    Hey… no problem 🙂
    I love a good challenge.
    According to the other page, this code should just slap in there and work… but it isn’t.
    Time to put on my Sherlock hat. 😛

    Hi!
    I was having this problem as well and I just figured out what was wrong: The TwentySixteen theme expects content.php to be in the folder “template-parts”. If you put it in the root of the child theme, it will be ignored. Just create a “template-parts” folder in your child theme and put your custom content.php there.

    Cheers!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to show excerpts on home page in WordPress (using Twenty’ is closed to new replies.