WordPress.org

Ready to get started?Download WordPress

Forums

Forever
[resolved] "continue reading," "older posts," and "newer posts" (7 posts)

  1. bakeologybylisa
    Member
    Posted 7 months ago #

    hi,

    i'm using the forever theme on bakeologybylisa.com, and i want to change the text of the "continue reading" link on the bottom of each post on the homepage, as well as the "older posts" and "newer posts" links at the bottom of the homepage.

    i have tried editing everywhere i can find these bits of text in my php files (using a child theme), but i can't seem to make the changes show up.

    any ideas on how to do this?

    thanks!

  2. kaniamea
    Member
    Posted 7 months ago #

    Hello, you can overwrite these with the function.php file in your child theme.

    line 187 where the Continue reading link is

    function forever_continue_reading_link() {
    	return ' <a class="more-link" href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'forever' ) . '</a>';
    }

    line 280, this is where you will find Older posts and Newer posts

    function forever_content_nav( $nav_id ) {
    	global $wp_query;
    
    	?>
    	<nav id="<?php echo $nav_id; ?>">
    		<h1 class="assistive-text section-heading"><?php _e( 'Post navigation', 'forever' ); ?></h1>
    
    	<?php if ( is_single() ) : // navigation links for single posts ?>
    
    		<?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'forever' ) . '</span> %title' ); ?>
    		<?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'forever' ) . '</span>' ); ?>
    
    	<?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
    
    		<?php if ( get_next_posts_link() ) : ?>
    		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'forever' ) ); ?></div>
    		<?php endif; ?>
    
    		<?php if ( get_previous_posts_link() ) : ?>
    		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'forever' ) ); ?></div>
    		<?php endif; ?>
    
    	<?php endif; ?>
    
    	</nav><!-- #<?php echo $nav_id; ?> -->
    	<?php
    }
    endif; // forever_content_nav
  3. bakeologybylisa
    Member
    Posted 7 months ago #

    thanks for the response. i'm a little new at this, so i'm still having trouble - i know i'm not supposed to have child theme functions with the same name as parent theme functions. so what do i need to change so that the functions have a different name, and so that the parent function stops running?

  4. kaniamea
    Member
    Posted 7 months ago #

    You can put the following code in your child functions.php file:

    <?php
    
    if ( ! function_exists( 'forever_content_nav' ) ):
    /**
     * Display navigation to next/previous pages when applicable
     *
     * @since Forever 1.0
     */
    function forever_content_nav( $nav_id ) {
    	global $wp_query;
    
    	?>
    	<nav id="<?php echo $nav_id; ?>">
    		<h1 class="assistive-text section-heading"><?php _e( 'Post navigation', 'forever' ); ?></h1>
    
    	<?php if ( is_single() ) : // navigation links for single posts ?>
    
    		<?php previous_post_link( '<div class="nav-previous">%link</div>', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'forever' ) . '</span> %title' ); ?>
    		<?php next_post_link( '<div class="nav-next">%link</div>', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'forever' ) . '</span>' ); ?>
    
    	<?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
    
    		<?php if ( get_next_posts_link() ) : ?>
    		<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'forever' ) ); ?></div>
    		<?php endif; ?>
    
    		<?php if ( get_previous_posts_link() ) : ?>
    		<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'forever' ) ); ?></div>
    		<?php endif; ?>
    
    	<?php endif; ?>
    
    	</nav><!-- #<?php echo $nav_id; ?> -->
    	<?php
    }
    endif; // forever_content_nav
    
    ?>

    Find and replace "Older posts" and "Newer posts" with the text you like.

    Also I just tried to overwrite the "Continue reading" function below but I got an error, so it would be great if the theme developers can assist you with that.

    function forever_continue_reading_link() {
    	return ' <a class="more-link" href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'forever' ) . '</a>';
    }
  5. bakeologybylisa
    Member
    Posted 7 months ago #

    thanks so much for the first part - it worked!

    now... still need help with the continue reading function!

  6. kaniamea
    Member
    Posted 7 months ago #

    Instead of overwriting function forever_continue_reading_link() you can put this to your child functions.php:

    add_action( 'after_setup_theme', 'forever_theme_setup' );
    function forever_theme_setup() {
    function forever_excerpt_more($more) {
    global $post;
    return '<a href="'. get_permalink($post->ID) . '" class="more-link"> Continue reading</a>';
    }
    add_filter('excerpt_more', 'forever_excerpt_more');
    }

    Replace the "Continue reading" text with whatever you like,

  7. bakeologybylisa
    Member
    Posted 7 months ago #

    it worked!! thanks so much!!

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.