• Resolved billbennett

    (@billbennett)


    I’ve been looking at customising the ‘continue reading’ link in a Twentyten child theme – I managed to change the ‘read more’ link in an earlier theme, but it looks far more complex in Twentyten. Has anyone found out how to do this?

Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter billbennett

    (@billbennett)

    Yes to all three.

    I tried searching for the content in the SQL database – and searching for the field name – I can’t find either, but they MUST be there somewhere.

    Could there be a problem with the way the loop calls the function?:

    <div class="entry-content">
    				<?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    			</div><!-- .entry-content -->

    the_excerpt() has no parameter – the above code is and was always unexplained to me.

    the ‘read-more’ text for the excerpt comes from a function in functions.php of the twenty ten theme:

    /**
     * Adds a pretty "Continue Reading" link to custom post excerpts.
     *
     * To override this link in a child theme, remove the filter and add your own
     * function tied to the get_the_excerpt filter hook.
     *
     * @since Twenty Ten 1.0
     * @return string Excerpt with a pretty "Continue Reading" link
     */
    function twentyten_custom_excerpt_more( $output ) {
    	if ( has_excerpt() && ! is_attachment() ) {
    		$output .= twentyten_continue_reading_link();
    	}
    	return $output;
    }
    add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );

    and this:

    /**
     * Returns a "Continue Reading" link for excerpts
     *
     * @since Twenty Ten 1.0
     * @return string "Continue Reading" link
     */
    function twentyten_continue_reading_link() {
    	return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
    }

    if you haven’t changed anything there, my suggested code should work (i would hope – tested in a child theme)

    you could paste the code of your functions.php into a https://wordpress.pastebin.com/ and post the link here for someone to check.

    Thread Starter billbennett

    (@billbennett)

    Thanks

    I appreciate this, I also hope it will help others.

    Functions.php is saved at: https://wordpress.pastebin.com/wPVm5Q9M

    this is the full functions.php of your child theme?

    have you changed anything in the functions.php of your parent theme, the Twenty Ten?

    you can also try:

    -change to the Twenty Ten theme and add the code directly into the functions.php of that theme;

    -deactivate all plugins, and when that solves the problem, re-activate one plugin after the other to see which triggers the problem.

    a link to your site might help to investigate this problem.

    Thread Starter billbennett

    (@billbennett)

    Yes, that’s it for functions.php – I had others previously, but have since stripped it back to nothing.

    I’m sure nothing is changed in the parent Twenty Ten functions, but to make certain, I’ll reload a fresh file.

    I’ll try making the change to the parent function.php file later – maybe later today.

    First I’m going to deactivate plug-ins and investigate this as a potential problem.

    My site is https://billbennett.co.nz

    Thread Starter billbennett

    (@billbennett)

    Definitely not a plug in problem…just deactivated and nothing changed

    Thread Starter billbennett

    (@billbennett)

    Moving the code to the parent functions.php didn’t seem to make any difference.

    i am at my limits, to what to suggest.
    i tried my suggested code locally in the twenty ten theme, and in a child theme; as well online in my twenty ten child theme based blog.
    no problems.
    however, each installation is unique, and the non-working might be caused by something that seems totally unrelated.

    —-
    an alternative way is to edit all occurrances of
    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    in loop.php (copied into the child theme; occurs twice – lines 110 and 138) to include the custom field text; for instance so:

    <?php $read_more = get_post_meta($post->ID, 'cont_read', true);
    $read_more = $read_more ? $read_more : 'Continue reading';
    the_content( __( $read_more . ' <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>

    and add a section in functions.php of the child theme:
    for instance: https://wordpress.pastebin.com/8EuqBfbH

    Thread Starter billbennett

    (@billbennett)

    Thanks Alchymyth. I think you’ve already gone well beyond the call of duty.

    I’ll give this other suggestion a try later.

    Thread Starter billbennett

    (@billbennett)

    This is now working, along the way I had to swap out the references to

    <?php the_content

    to

    <?php the-excerpt

    but that fixed it. Maybe this was the problem in the first place?

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Custom "continue reading" in Twentyten’ is closed to new replies.