Customizing wordpress twenty fifteen theme – Basic PHP

In the official WordPress theme twenty fifteen we have the following code inside the content.php file:

<div class="entry-content">
    <?php
        /* translators: %s: Name of current post */
        the_content( sprintf(
            __( 'Continue reading %s', 'twentyfifteen' ),
            the_title( '<span class="screen-reader-text">', '</span>', false )
        ) );

        wp_link_pages( array(
            'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
            'after'       => '</div>',
            'link_before' => '<span>',
            'link_after'  => '</span>',
            'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
            'separator'   => '<span class="screen-reader-text">, </span>',
        ) );
    ?>
</div><!-- .entry-content -->

I am trying to apply a custom style to the “Continue reading” link (and only the link) but the problem is that the “Continue reading” is already a part of the div with the “entry-content” style.

Read More

Preferably I would want to have the “Continue reading” somewhere else but I am quite confused on how to do so.

I am not too familiar with PHP, which is probably the main problem here to be honest. I have spent about an hour trying to research how to do this but I probably don’t have the experience to understand what I am reading.

SOLVED: Edit/Update:

The following code worked for me. This will insert the read more link:

<div class="more-link">
<a href="<?php the_permalink(); ?>">Read more</a>
</div>

I also changed:

the_content( sprintf(
        __( 'Continue reading %s', 'twentyfifteen' ),
        the_title( '<span class="screen-reader-text">', '</span>', false )

to this:

the_content('');

Related posts

1 comment

  1. You could replace the sprint_f part with quotes (the_content(”)) and place the readmore link wherever you want using the_permalink()

    Here is an example :

    <div class="entry-content">
    <?php
        /* translators: %s: Name of current post */
        the_content('');
    
    ?>
    <a href="<?php the_permalink(); ?>">Read more</a>
    <?php
        wp_link_pages( array(
            'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
            'after'       => '</div>',
            'link_before' => '<span>',
            'link_after'  => '</span>',
            'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
            'separator'   => '<span class="screen-reader-text">, </span>',
        ) );
    ?>
    </div><!-- .entry-content -->
    

Comments are closed.