• Hi
    Same posts are displayed in all blog pages in my website.

    global $post;
    $page_id = $post->ID;
    $page_custom_fields = get_post_custom( $page_id);
    
    $page_sidebar_positioning = null;
    if (isset($page_custom_fields['page_sidebar_positioning'])) {
    	$page_sidebar_positioning = $page_custom_fields['page_sidebar_positioning'][0];
    	$page_sidebar_positioning = empty($page_sidebar_positioning) ? '' : $page_sidebar_positioning;
    }
    
    $section_class = 'full-width';
    if ($page_sidebar_positioning == 'both')
    	$section_class = 'one-half';
    else if ($page_sidebar_positioning == 'left' || $page_sidebar_positioning == 'right')
    	$section_class = 'three-fourth';
    
    $posts_per_page = get_option('posts_per_page');
    
    if ( get_query_var('paged') ) {
        $paged = get_query_var('paged');
    } else if ( get_query_var('page') ) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    	'paged'			   => $page,
    	'posts_per_page'   => $posts_per_page,
    	'offset'           => 0,
    	'category'         => '',
    	'post_type'        => 'post',
    	'post_status'      => 'publish'); 
    
    ?>

    [Moderator Note: Please post code between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    Any error in the above code. Please help me out as I am stumbling.
    Thanks in advance
    JassV

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You get the same results from your custom query no matter what page number is requested because ‘paged’ and ‘offset’ arguments are incompatible together. Start with getting rid of ‘offset’ and ‘category’ arguments, they are not needed and can hinder you getting the right results.

    If you still have trouble, it’s probably because the main query’s ‘paged’ argument is not appropriate for the custom query. It may be necessary to manage the custom query pagination completely separate from the main query, which means a different query var for custom query pagination and custom page links to match.

Viewing 1 replies (of 1 total)
  • The topic ‘Same posts in All pages’ is closed to new replies.