Viewing 15 replies - 1 through 15 (of 19 total)
  • wpjobz

    (@wpjobz)

    It’s a pretty old theme. It hasn’t been updated for a couple of years.

    Have you considered updating / upgrading to a newer theme?

    Thread Starter gregtallent2

    (@gregtallent2)

    Thanks, wpjobz.

    I’m using a custom home page. I’m using a simple single post page which should have a list of recommended posts and then then previous post link at the bottom.

    Can you recommend a new theme that does a simple job?

    wpjobz

    (@wpjobz)

    Not that I know from memory. There are so many to choose from though….

    https://www.ads-software.com/themes/browse/new/

    Thread Starter gregtallent2

    (@gregtallent2)

    Thanks, will take a look. Probably quicker than trying to fix the code in Emphaino.

    wpjobz

    (@wpjobz)

    For sure. There will be a way around it but then there are other issues like for example its not responsive.

    Open it the browser and then slowly make it narrower. It should adjust so whatever device you are using it displays correctly. All newer themes do this but older themes may not.

    Thread Starter gregtallent2

    (@gregtallent2)

    Thanks.

    Michael

    (@alchymyth)

    is the ‘recommended‘ section part of the theme, or added via plugin or custom code?

    if you have edited single.php in any way, please post the full code; also post the codes of any template parts which might get called by single.php.

    the link at the bottom is a ‘previous posts‘ link, and refers possibly to the list of the ‘recommended’ posts (although it is not working for that either), not to the single post.

    I could not find a link to the single ‘previous post’ on the page.

    Thread Starter gregtallent2

    (@gregtallent2)

    Thanks, alchymyth.

    Haven’t changed the recommended section.

    Link to single ‘previous post’ is broken as mentioned in top message.

    Here’s the full code:

    <?php
    
    /**
    
     * The Template for displaying all single posts.
    
     *
    
     * @package Emphaino
    
     * @since Emphaino 1.0
    
     */
    
    get_header(); ?>
    
    		<div id="primary" class="content-area">
    
    			<div id="content" class="site-content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php // emphaino_content_nav( 'nav-above' ); ?>
    
    				<?php get_template_part( 'content', 'single' ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    			</div>
    
    			<!-- #content .site-content -->
    
    		</div>
    
    		<div class="div_clear"></div>
    
    		<div class="bottom_post">
    
    			<?php
    
    				foreach((get_the_category()) as $category) {
    
    					$cat=$category->cat_name . ' ';
    
    				}
    
    				?>
    
    		<h1 class="more_post">Recommended</h1>
    
    		<div id="primary" class="content-area">
    
    			<div id="content" class="site-content" role="main">
    
    			<?php 
    
    				$post_id=get_the_ID();
    
    $tags = wp_get_post_tags($post_id);
    $i = 0;
    foreach ( $tags as $tag ) {
    	$tag_array[$i] = $tag->term_id;
    	$i++;
    
    }
    
    $original_query = $wp_query;
    $wp_query = null;
    $args=array('posts_per_page'=>30, 'tag__in' => $tag_array, 'post__not_in' => array($post_id)
    );
    $wp_query = new WP_Query( $args );
    
    //				query_posts(array(
    //
    //					'post_type' => 'post',
    //
    //					'tag_in' => $tag_array
    //
    //
    //				) );  
    
    			?>
    
    			<?php if ( have_posts() ) : ?>
    
    				<?php if( is_paged() ) emphaino_content_nav( 'nav-above' ); ?>
    
    				<?php if ( 'dynamic_grid_excerpts' == get_theme_mod( 'posts_layout', emphaino_default_settings('posts_layout') ) ) echo '<div id="dynamic-grid" class="clearfix">'; ?>
    
    					<?php /* Start the Loop */ ?>
    
    					<?php while ( have_posts() ) : the_post(); ?>
    
    						<?php
    
    							/* Include the Post-Format-specific template for the content.
    
    							 * If you want to overload this in a child theme then include a file
    
    							 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    
    							 */
    
    							get_template_part( 'content', get_post_format() );
    
    						?>
    
    					<?php endwhile; ?>
    
    				<?php if ( 'dynamic_grid_excerpts' == get_theme_mod( 'posts_layout', emphaino_default_settings('posts_layout') ) ) echo '</div> <!-- #dynamic-grid -->'; ?>
    
    				<?php emphaino_content_nav( 'nav-below' ); ?>
    
    			<?php else : ?>
    
    				<?php get_template_part( 'no-results', 'index' ); ?>
    
    			<?php endif; ?>
    
    <?php get_footer(); ?>
    
    			</div><!-- #content .site-content -->
    
    		</div>
    
    		</div>
    
    		<!-- #primary .content-area -->
    Thread Starter gregtallent2

    (@gregtallent2)

    By the way, doing a search on say ‘video’ and the older posts link works fine.

    Michael

    (@alchymyth)

    this function <?php emphaino_content_nav( 'nav-below' ); ?> adjusts its output automatically to single or index pages;
    as you have changed the original $wp_query, the function now assumes that you are referring to multiple posts;

    try to reset the query before calling the content nav;

    example:

    <?php
    $wp_query = null;
    $wp_query = $original_query;
    emphaino_content_nav( 'nav-below' ); ?>
    Thread Starter gregtallent2

    (@gregtallent2)

    Thank you, alchymyth.

    It now generates links to previous and next posts, but they’re the same ones… ??

    Thread Starter gregtallent2

    (@gregtallent2)

    .. on every post!

    Michael

    (@alchymyth)

    It now generates links to previous and next posts

    do you want to get a link to the next/previous single post of your site, or to the next/previous posts of the ‘recommended‘ list?

    what is the full code of single.php right now after your changes?

    Thread Starter gregtallent2

    (@gregtallent2)

    Link to the recommended list, please.

    Full code now:

    <?php
    
    /**
    
     * The Template for displaying all single posts.
    
     *
    
     * @package Emphaino
    
     * @since Emphaino 1.0
    
     */
    
    get_header(); ?>
    
    		<div id="primary" class="content-area">
    
    			<div id="content" class="site-content" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php // emphaino_content_nav( 'nav-above' ); ?>
    
    				<?php get_template_part( 'content', 'single' ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    			</div>
    
    			<!-- #content .site-content -->
    
    		</div>
    
    		<div class="div_clear"></div>
    
    		<div class="bottom_post">
    
    			<?php
    
    				foreach((get_the_category()) as $category) {
    
    					$cat=$category->cat_name . ' ';
    
    				}
    
    				?>
    
    		<h1 class="more_post">Recommended</h1>
    
    		<div id="primary" class="content-area">
    
    			<div id="content" class="site-content" role="main">
    
    			<?php 
    
    				$post_id=get_the_ID();
    
    $tags = wp_get_post_tags($post_id);
    $i = 0;
    foreach ( $tags as $tag ) {
    	$tag_array[$i] = $tag->term_id;
    	$i++;
    
    }
    
    $original_query = $wp_query;
    $wp_query = null;
    $args=array('posts_per_page'=>30, 'tag__in' => $tag_array, 'post__not_in' => array($post_id)
    );
    $wp_query = new WP_Query( $args );
    
    //				query_posts(array(
    //
    //					'post_type' => 'post',
    //
    //					'tag_in' => $tag_array
    //
    //
    //				) );  
    
    			?>
    
    			<?php if ( have_posts() ) : ?>
    
    				<?php if( is_paged() ) emphaino_content_nav( 'nav-above' ); ?>
    
    				<?php if ( 'dynamic_grid_excerpts' == get_theme_mod( 'posts_layout', emphaino_default_settings('posts_layout') ) ) echo '<div id="dynamic-grid" class="clearfix">'; ?>
    
    					<?php /* Start the Loop */ ?>
    
    					<?php while ( have_posts() ) : the_post(); ?>
    
    						<?php
    
    							/* Include the Post-Format-specific template for the content.
    
    							 * If you want to overload this in a child theme then include a file
    
    							 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    
    							 */
    
    							get_template_part( 'content', get_post_format() );
    
    						?>
    
    					<?php endwhile; ?>
    
    				<?php if ( 'dynamic_grid_excerpts' == get_theme_mod( 'posts_layout', emphaino_default_settings('posts_layout') ) ) echo '</div> <!-- #dynamic-grid -->'; ?>
    
    				<?php
    				$wp_query = null;
    $wp_query = $original_query;
    
    				emphaino_content_nav( 'nav-below' ); ?>
    
    			<?php else : ?>
    
    				<?php get_template_part( 'no-results', 'index' ); ?>
    
    			<?php endif; ?>
    
    <?php get_footer(); ?>
    
    			</div><!-- #content .site-content -->
    
    		</div>
    
    		</div>
    
    		<!-- #primary .content-area -->

    Michael

    (@alchymyth)

    try to include the ‘paged’ parameter into the query args:

    $args=array('posts_per_page'=>30, 'tag__in' => $tag_array, 'post__not_in' => array($post_id), 'paged' => get_query_var( 'paged' )

    or if the above does not work:

    $args=array('posts_per_page'=>30, 'tag__in' => $tag_array, 'post__not_in' => array($post_id), 'paged' => get_query_var( 'page' )

    and you might possibly need to remove those lines again:

    $wp_query = null;
    $wp_query = $original_query;
Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Single post page: previous post link not working’ is closed to new replies.