Support » Fixing WordPress » Change wording of Older Posts in Twenty twelve

  • Hi!

    I would like to changed the Older Posts at the bottom of the page and keep just the arrow! Can anyone help? Thanks a lot!

Viewing 13 replies - 1 through 13 (of 13 total)
  • This is editable within the theme files, but I’d highly recommend using a child theme unless you don’t plan on updating the Twenty Twelve theme.

    Unfortunately, WordPress does not provide a filter for the previous & next post links. You would need to filter the_content and make the change using a function like this in your functions.php file:

    function prev_next_links_06122013( $content ) {
        $content = str_replace( 'Older Posts', '', $content );
        $content = str_replace( 'Newer Posts', '', $content );
        return $content;
    add_filter( 'the_content', 'prev_next_links_06122013' );

    That function would remove the words “Older Posts” and “Newer Posts” from each post/page.

    Also, since str_replace is case sensitive, it won’t remove the phrase “older posts” or “Older posts” if that were in the content of the post or page.

    And yes, use a child theme! 🙂

    Thanks! I have a child theme and added that code to the functions.php and it still shows older posts… hmmm…

    Oh, right. Those links are not a part of the post content; they are added by the page template after the_content(). My bad.

    I did find this article, which suggests that this would work:

    function prev_link_06122013( $content ) {
        $content = str_replace( 'Older Posts', '', $content );
        return $content;
    add_filter( 'previous_post_link', 'prev_link_06122013' );
    function next_link_06122013( $content ) {
        $content = str_replace( 'Newer Posts', '', $content );
        return $content;
    add_filter( 'next_post_link', 'next_link_06122013' );

    So I should not post this on the functions.php? but i don’t have the_content() in my index.php. I’m relatively new to this, sorry for asking so many questions! Thanks a lot for your help!

    Yes, the code I gave you should go in your child theme functions.php, after the opening <?php tag.

    (And yes, your index.php probably uses the_excerpt(); instead. Sorry, my first solution was a bit rushed and not very well thought out.)

    It still doesn’t work. I’m probably doing something wrong… here’s my website:

    I’ve added that text to the functions.php file, uploaded on the ftp directory of my child theme, and refreshed my page and the “older posts” still appear.

    Thanks for all your help, much appreciated!

    Sorry, I guess I should probably test my code before I post it! 🙂

    Turns out, those filter hooks only work when the singular functions next_post_link() and previous_post_link() are used.

    You could just copy index.php over from the parent theme into your child theme directory, and change this on line 28:

    <?php twentytwelve_content_nav( 'nav-below' ); ?>

    …to something like this:

    <?php my_child_theme_content_nav( 'nav-below' ); ?>

    Then, in your functions.php file, add this:

    function my_child_theme_content_nav( $html_id ) {
    	global $wp_query;
    	$html_id = esc_attr( $html_id );
    	if ( $wp_query->max_num_pages > 1 ) : ?>
    		<nav id="<?php echo $html_id; ?>" class="navigation" role="navigation">
    			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    			<div class="nav-previous alignleft"><?php next_posts_link( __( '<span class="meta-nav">←</span>', 'twentytwelve' ) ); ?></div>
    			<div class="nav-next alignright"><?php previous_posts_link( __( '<span class="meta-nav">→</span>', 'twentytwelve' ) ); ?></div>
    		</nav><!-- #<?php echo $html_id; ?> .navigation -->
    	<?php endif;

    This way, you are creating a modified version of the Twenty Twelve theme function that outputs the pagination links, and calling your new function from your template files.

    Hey Shaun!

    It still doesn’t work. I’ve even uploaded the plugin WP-Paginate, which would keep numbers and arrows and it doesn’t work either. I am wondering, would it be possible that i have other files affecting my functions.php file, like in the hierarchy?

    Currently, my child theme directory contains:

    thanks so much! there must be something i’m not doing right…

    Oh wow, I’m really sorry but it seems like my child theme wasn’t activated!!! And when I did activate it, the twenty twelve theme wasn’t there, so I have a lot of work to do!

    Hey Shaun! So I tried all of the above on my now working child theme and the last suggestion worked (with modifications to the index.php)!!! you can check it out at!

    Thanks soooo much! Especially for your patience!

    Glad to help!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Change wording of Older Posts in Twenty twelve’ is closed to new replies.