Modify inc/template-tags.php in child theme?

Is it possible to modify the template-tags file in my child theme? It seems that the parent version is always called and there is not a clear way to override it. Either it only uses the parent version, or it gives me a fatal error due to duplication.

I am trying to change the code so it only shows posts in the current category in the post navigation at the bottom of the page.

Many thanks in advance.

Hello there,

The functions which are plugable; meaning that they are wrapped with function_exists check, are able to be overridden from child theme’s functions.php file.

So you just need to duplicate this function the_posts_navigation() to modify the posts navigation and put it into your child theme’s functions.php file.

Regards,
Kharis

Thank you, that clarifies the ability to call the template-tags file in the child theme. I figured that was the case since the calling of the file in the parent theme was not pluggable.

However, when I update the functions.php as follows, it does not change the post navigation to category only. But when I change it in the parent template-tags, it does. Am I missing something basic here?

if ( ! function_exists( ‘the_posts_navigation’ ) ) :
/**

  • Display navigation to next/previous set of posts when applicable.

  • @todo Remove this function when WordPress 4.3 is released.
    */
    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’, ‘sydney’ ); ?></h2>
    <div class=“nav-links clearfix”>

     	&lt;?php if ( get_next_posts_link() ) : ?&gt;
     	&lt;div class="nav-previous"&gt;&lt;?php next_posts_link( __( 'Older posts', 'sydney', TRUE ) ); ?&gt;&lt;/div&gt;
     	&lt;?php endif; ?&gt;
    
     	&lt;?php if ( get_previous_posts_link() ) : ?&gt;
     	&lt;div class="nav-next"&gt;&lt;?php previous_posts_link( __( 'Newer posts', 'sydney', TRUE ) ); ?&gt;&lt;/div&gt;
     	&lt;?php endif; ?&gt;
    
     &lt;/div&gt;&lt;!-- .nav-links --&gt;
    

    </nav><!-- .navigation -->
    <?php
    }
    endif;

I figured out my mistake. I was working with the wrong set of functions. When I changed the functions.php in my child theme as follows, it worked as expected.

if ( ! function_exists( ‘sydney_post_navigation’ ) ) :
function sydney_post_navigation() {
// Don’t print empty markup if there’s nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, ‘’, true );
$next = get_adjacent_post( false, ‘’, false );

if ( ! $next &amp;&amp; ! $previous ) {
	return;
}
?&gt;
&lt;nav class="navigation post-navigation" role="navigation"&gt;
	&lt;h2 class="screen-reader-text"&gt;&lt;?php _e( 'Post navigation', 'sydney' ); ?&gt;&lt;/h2&gt;
	&lt;div class="nav-links clearfix"&gt;
		&lt;?php
			previous_post_link( '&lt;div class="nav-previous"&gt;&lt;i class="fa fa-long-arrow-left"&gt;&lt;/i&gt; %link&lt;/div&gt;', '%title', TRUE );
			next_post_link( '&lt;div class="nav-next"&gt;%link, &lt;i class="fa fa-long-arrow-right"&gt;&lt;/i&gt;&lt;/div&gt;', '%title', TRUE );
		?&gt;
	&lt;/div&gt;&lt;!-- .nav-links --&gt;
&lt;/nav&gt;&lt;!-- .navigation --&gt;
&lt;?php

}
endif;

Thank you for all your help. Great theme!

Awesome! You figured it out.

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

If you don’t mind, could you please rate our Sydney theme here:https://wordpress.org/support/view/theme-reviews/sydney#postform? We would highly appreciate it if you do so.

Regards,
Kharis