Title: Function the_posts_navigation() on child theme
Last modified: August 31, 2016

---

# Function the_posts_navigation() on child theme

 *  Resolved [Argumentum](https://wordpress.org/support/users/argumentum0/)
 * (@argumentum0)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/function-the_posts_navigation-on-child-theme/)
 * Hello,
 * I am trying to use the plugin WP-PageNavi ([https://wordpress.org/plugins/wp-pagenavi/](https://wordpress.org/plugins/wp-pagenavi/))
   to customise the page navigation links.
 * To use it, I have to replace the calls to `next_posts_link()` and `previous_posts_link()`.
   In Gazette, they are located in the file `\inc\template-tags.php` (function `
   the_posts_navigation()`).
 * From what I learnt from this thread ([https://wordpress.org/support/topic/post-navigation-background-images?replies=6](https://wordpress.org/support/topic/post-navigation-background-images?replies=6)),`
   the_posts_navigation()` is a “pluggable” function (it is enclosed by `if ( ! 
   function_exists( 'the_posts_navigation' ) ) :`).
 * So I tried to simply copy the function `the_posts_navigation()` to my child theme
   and replace the necessary lines in order to use WP-PageNavi. “Since `the_posts_navigation()`
   is a pluggable function,” I thought, “I won’t have to do anything else”.
 * Unfortunately, I was wrong. It’s not working.
 * I use the plugin Code Snippets ([https://wordpress.org/plugins/code-snippets/](https://wordpress.org/plugins/code-snippets/))
   to manage my custom snippets, and when I try to activate the snippet below…
 *     ```
       function the_posts_navigation() {
       	// Don't print empty markup if there's only one page.
       	if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
       		return;
       	}
       	?>
       	<nav class="navigation posts-navigation" role="navigation">
       		<h2 class="screen-reader-text"><?php _e( 'Posts navigation', 'gazette' ); ?></h2>
       		<div class="nav-links">
   
       			<?php if ( get_next_posts_link() ) : ?>
       			<?php wp_pagenavi(); ?>
       			<?php endif; ?>
   
       			<?php if ( get_previous_posts_link() ) : ?>
       			<?php wp_pagenavi(); ?>
       			<?php endif; ?>
   
       		</div><!-- .nav-links -->
       	</nav><!-- .navigation -->
       	<?php
       }
       ```
   
 * I get this error:
 * >  The code snippet you are trying to save produced a fatal error on line 22:
   > **
   > Cannot redeclare the_posts_navigation() (previously declared in /home/[redacted]/
   > public_html/wp-includes/link-template.php:2462)**
 * What should I do to customise `the_posts_navigation()` on my child theme so I
   can use WP-PageNavi?
 * Thanks again!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Argumentum](https://wordpress.org/support/users/argumentum0/)
 * (@argumentum0)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/function-the_posts_navigation-on-child-theme/#post-7133201)
 * I got this working.
 * More information here: [https://wordpress.org/support/topic/cannot-redeclare-the_posts_navigation-link-templatephp?replies=8](https://wordpress.org/support/topic/cannot-redeclare-the_posts_navigation-link-templatephp?replies=8)

Viewing 1 replies (of 1 total)

The topic ‘Function the_posts_navigation() on child theme’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/gazette/1.1.1/screenshot.png)
 * Gazette
 * [Support Threads](https://wordpress.org/support/theme/gazette/)
 * [Active Topics](https://wordpress.org/support/theme/gazette/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/gazette/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/gazette/reviews/)

## Tags

 * [child theme](https://wordpress.org/support/topic-tag/child-theme/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [snippet](https://wordpress.org/support/topic-tag/snippet/)

 * 1 reply
 * 1 participant
 * Last reply from: [Argumentum](https://wordpress.org/support/users/argumentum0/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/function-the_posts_navigation-on-child-theme/#post-7133201)
 * Status: resolved