• Resolved lebowzki

    (@lebowzki)


    i need to change text for previous next (the links that switches between posts) in the twenty eleven child theme
    to something like back forward etc. where should i look?
    seems other themes has this in index.php but i can’t see this in twenty eleven

Viewing 15 replies - 1 through 15 (of 15 total)
  • it is in functions.php, starting with:

    function twentyeleven_content_nav( $nav_id ) {
    ...

    because it is pluggable, you can create a function with the same name in functions.php of your child theme;

    simply copy the full function from functions.php of the parent theme, and paste it into functions.php of the child theme;
    then edit the text…

    Thread Starter lebowzki

    (@lebowzki)

    i copied the function but changing “nav-previous” “nav-next”
    didnt changed the text
    what else i should change?
    ideally i just want to keep arrows <- ->
    instead of text

    the visible text is:

    Older posts

    (within this line:
    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyeleven' ) ); ?></div> )

    and:

    Newer posts

    (within this line:
    <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div> )

    to just keep the arrows, delete those two texts.

    you only changed some css classes.

    Thread Starter lebowzki

    (@lebowzki)

    sorry, i dont get something obviously
    do you mean i have to delete text Newer posts and Older posts?
    it didnt changed anything i still have previous, next text

    Thread Starter lebowzki

    (@lebowzki)

    i copied this into my child themes functions.php

    function twentyeleven_content_nav( $nav_id ) {
    	global $wp_query;
    
    	if ( $wp_query->max_num_pages > 1 ) : ?>
    		<nav id="<?php echo $nav_id; ?>">
    			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
    			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> ', 'twentyeleven' ) ); ?></div>
    			<div class="nav-next"><?php previous_posts_link( __( '<span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
    		</nav><!-- #nav-above -->
    	<?php endif;
    }
    Thread Starter lebowzki

    (@lebowzki)

    hello? i still can’t change previous, next text to something else
    which line exactly i should change?

    there is also the link between single posts
    – I should have thought of those as well ;-(

    edit single.php:

    <span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">&larr;</span> Previous', 'twentyeleven' ) ); ?></span>
    						<span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></span>

    change to:

    <span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">&larr;</span>', 'twentyeleven' ) ); ?></span>
    						<span class="nav-next"><?php next_post_link( '%link', __( '<span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></span>

    Hi,

    When I change something in the function.php (child theme), it breaks down the whole site. Any idea as to why this happens?

    make sure not to break the php syntax;

    please post details on what you are changing.

    it might help if you can describe what you want to change in functions.php of the child theme;
    and if you can post the full functions.php as it is before the changes.

    see forum guidelines for posting code

    I have not made any modifications in the functions.php – yet, so it is the latest twenty eleven version copied in to my child theme. I can still post it if you prefer.

    What I want to change is just to remove the wordings “Older posts” and “Never Posts” and just keep the arrows. So, I tried deleting those two statements in lines 454 and 456 – and that broke my site down.

    so it is the latest twenty eleven version copied in to my child theme.

    do not copy the functions.php from the parent theme into the child theme.
    https://codex.www.ads-software.com/Child_Themes#Using_functions.php

    create a new empty functions.php, starting with just <?php in the first line (no empty lines or space characters before that).

    then add the whole ‘twentyeleven_content_nav()’ into functions.php:

    function twentyeleven_content_nav( $nav_id ) {
    	global $wp_query;
    
    	if ( $wp_query->max_num_pages > 1 ) : ?>
    		<nav id="<?php echo $nav_id; ?>">
    			<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
    			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
    			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
    		</nav><!-- #nav-above -->
    	<?php endif;
    }

    now you can edit it, and remove whatever you need …

    Ahh – thank you very much – that did the job ??

    So, I am sorry to bother you again. However, now I need to do some other changes requiering modifications in functions.php. Do I use the one and same file I created in my child-theme or do I need one functions.php file per change?

    Same one.

    Thank You!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘how to rename previous next in the twenty eleven theme?’ is closed to new replies.