• I’d like to change the “older posts” text on TwentyTen via functions.php (not editing loop.php). I tried with this but without any luck:

    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( 'Navigazione', 'twentyten' ); ?></h3>
    			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Articoli successivi', 'twentyten' ) ); ?></div>
    			<div class="nav-next"><?php previous_posts_link( __( 'A <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div>
    		</nav><!-- #nav-above -->
    	<?php endif;
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Don’t edit the Twenty Ten theme. First create a child theme for your changes.

    Thread Starter multiformeingegno

    (@lorenzone92)

    I did that already, forgot to say I’m working on a child theme. -.-
    The problem is that I want to edit that text in category.php, where the loop is called through get_template_part( ‘loop’, ‘category’ ); (so I can’t edit html itself). And I don’t want to edit loop.php. I want to modify that text through functions.php

    You can’t. The hooks simply aren’t in the parent theme to modify the nav links via the child’s functions.php file. What you’d actually need to do is create a loop-category.php template file:

    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
    <div class="entry-meta">
    <?php twentyten_posted_on(); ?>
    </div><!-- .entry-meta -->
    
    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    
    <div class="entry-utility">
    <?php if ( count( get_the_category() ) ) : ?>
    <span class="cat-links">
    <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
    </span>
    <span class="meta-sep">|</span>
    <?php endif; ?>
    <?php
    $tags_list = get_the_tag_list( '', ', ' );
    if ( $tags_list ):
    ?>
    <span class="tag-links">
    <?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
    </span>
    <span class="meta-sep">|</span>
    <?php endif; ?>
    <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    </div><!-- .entry-utility -->
    </div><!-- #post-## -->
    
    <?php comments_template( '', true ); ?>
    
    <?php endwhile; // End the loop. Whew. ?>
    
    if ( $wp_query->max_num_pages > 1 ) : ?>
    <nav id="<?php echo $nav_id; ?>">
    <h3 class="assistive-text"><?php _e( 'Navigazione', 'twentyten' ); ?></h3>
    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">?</span> Articoli successivi', 'twentyten' ) ); ?></div>
    <div class="nav-next"><?php previous_posts_link( __( 'A <span class="meta-nav">?</span>', 'twentyten' ) ); ?></div>
    </nav><!-- #nav-above -->
    <?php endif;
    <!-- #nav-below -->
    Thread Starter multiformeingegno

    (@lorenzone92)

    So if I copy the loop.php from the parent to the child theme would that code work on functions.php?

    Thread Starter multiformeingegno

    (@lorenzone92)

    Anyway it’s a bit weird.. why does this code work if I don’t have the loop.php in my child theme and the other (which acts on loop.php code too) doesn’t?

    function new_excerpt_more($more) {
           global $post;
        return ' … <a href="'. get_permalink($post->ID) . '">Continua <span class="meta-nav">→</span></a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more',100);

    So if I copy the loop.php from the parent to the child theme would that code work on functions.php?

    No.

    why does this code work

    Because you’re amending the output of the_excerpt() via the excerpt_more filter. There isn’t a filter for what you want to do with those nav links.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Change "Older posts" text on TwentyTen through functions.php’ is closed to new replies.