Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter gregtallent2

    (@gregtallent2)

    Thank you, alchymyth.

    I get a
    Call to a member function get() on a non-object in /home4/bearstor/public_html/wp-includes/query.php on line 28

    .. error with both suggestions, having taken out these lines:
    $wp_query = null;
    $wp_query = $original_query;

    The call just doesn’t like the new parameter.

    the error message was caused by my mistake, I suggested the wrong location to add the line to get the paged parameter.

    this relevant code section seems to work:

    <?php 
    
    				$post_id=get_the_ID();
    
    $tags = wp_get_post_tags($post_id);
    foreach ( $tags as $tag ) {
    	$tag_array[] = $tag->term_id;
    }
    
    $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
    
    $original_query = $wp_query;
    $wp_query = null;
    $args=array('posts_per_page'=>3,
    'tag__in' => $tag_array,
    'post__not_in' => array($post_id),
    'paged' => $paged
    );
    $wp_query = new WP_Query( $args );

    you also need to add this to functions.php of your theme:

    add_filter('redirect_canonical','my_disable_redirect_canonical');
    
    function my_disable_redirect_canonical( $redirect_url ) {
        if ( is_singular( 'post' ) )
        $redirect_url = false;
        return $redirect_url;
    }

    ref: https://www.ads-software.com/support/topic/pagination-on-singlephp-causing-301-redirect?replies=10

    Thread Starter gregtallent2

    (@gregtallent2)

    Thank you very much for your suggestions, alchymyth.

    But, that doesn’t work. Same link generated. I think I’m going to go to a newer theme.

    Thread Starter gregtallent2

    (@gregtallent2)

    Got the single page ‘newer’ and ‘older’ posts links working. Had to go back to the original single.php file without any of my modifications. ??

    Thank you, again, alchymyth.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Single post page: previous post link not working’ is closed to new replies.