• Resolved webmasteral

    (@webmasteral)


    I have been unable to get my themes template-tags.php to be replaced by child theme functions so that they only link within a category

    Current code of template-tags.php

    function twentyfourteen_post_nav() {
    	// 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 && ! $previous ) {
    		return;
    	}
    
    	?>
    	<nav class="navigation post-navigation" role="navigation">
    		<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentyfourteen' ); ?></h1>
    		<div class="nav-links">
    			<?php
    			if ( is_attachment() ) :
    				previous_post_link( '%link', __( '<span class="meta-nav">Published In SOMETHING A</span>%title', 'twentyfourteen' ) );
    			else :
    				previous_post_link( '%link', __( '<span class="meta-nav">Previous Post NOT THIS B</span>%title', 'twentyfourteen' ) );
    				next_post_link( '%link', __( '<span class="meta-nav">Next Post WACKY C</span>%title', 'twentyfourteen' ) );
    			endif;
    			?>
    		</div><!-- .nav-links -->
    	</nav><!-- .navigation -->

    I am unclear as to what I need to add to child functions.php to get the result I am looking for. I have also tried to change false to true per WP prev link codex. It will correct the prev link but not the next link.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter webmasteral

    (@webmasteral)

    so adding raw
    `else :
    previous_post_link( ‘%link’, __( ‘<span class=”meta-nav”>Previous Post NOT THIS B</span>%title’, ‘twentyfourteen’ ) );
    next_post_link( ‘%link’, __( ‘<span class=”meta-nav”>Next Post WACKY C</span>%title’, ‘twentyfourteen’ ) );
    previous_post_link(‘%link’, ‘Previous in category’, TRUE);
    next_post_link(‘%link’, ‘Next in category’, TRUE);
    endif;`

    works. Trying to manipulate the org code future.

    Thread Starter webmasteral

    (@webmasteral)

    The following code seems to have solved half of my problem
    `else :
    //previous_post_link( ‘%link’, __( ‘<span class=”meta-nav”>Previous Post NOT THIS B</span>%title’, ‘twentyfourteen’ ) );
    //next_post_link( ‘%link’, __( ‘<span class=”meta-nav”>Next Post WACKY C</span>%title’, ‘twentyfourteen’ ) );
    previous_post_link(‘%link’,__( ‘<span class=”meta-nav”>Previous Post </span>%title’, ‘twentyfourteen’ ), TRUE);
    next_post_link(‘%link’, __( ‘<span class=”meta-nav”>Next Post </span>%title’, ‘twentyfourteen’ ), TRUE);
    endif;`

    Now the problem is that this change was made inside the parent theme inc/template-tags.php and I need to somehow get this into the child theme and thats where im stuck now.

    Thread Starter webmasteral

    (@webmasteral)

    adding
    include( get_stylesheet_directory() . '/inc/template-tags.php' );
    into child functions.php results in WP white page of death

    Anyone have any ideas?

    Thread Starter webmasteral

    (@webmasteral)

    Closing this topic as the issue is now adding in a child template-tags.php file

    previous_post_link and next_post_link by post/details page.

    I want cache this core query

    SELECT p.ID
    FROM wp_posts AS p
    INNER JOIN wp_term_relationships AS tr
    ON p.ID = tr.object_id
    INNER JOIN wp_term_taxonomy tt
    ON tr.term_taxonomy_id = tt.term_taxonomy_id
    WHERE p.post_date < ‘2015-11-30 00:15:10’
    AND p.post_type = ‘post’
    AND tt.taxonomy = ‘category’
    AND tt.term_id IN (xxx)
    AND ( p.post_status = ‘publish’
    OR p.post_status = ‘private’ )
    ORDER BY p.post_date DESC
    LIMIT 1

    Please help me….
    sorry for my english

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘previous_post_link and next_post_link by category’ is closed to new replies.