WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#35847 new defect (bug)

Issue with blog roll pagination on static frontpage

Reported by: finomeno Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 4.4.2
Component: Canonical Keywords: needs-patch
Focuses: Cc:

Description

This is a follow-up to #35344.

Still having this problem on 4.4.2 with or without 35344.2.diff applied. The query.php in 4.4.2 is way too different to apply 35344.diff.

In my case this bug only affects the blog roll on a static front page, and instead of redirecting to the homepage it strips the page number from the URL and tries to load sitename.com/page/ which, in turn, returns a 404.

The same page, unset from being the frontpage, works fine.

Change History (4)

#1 follow-ups: @dd32
2 years ago

Hi @finomeno

Can you clarify what you mean by "blog roll"? Are you referring to the Blogroll functionality that lists other sites, or are you referring to embedding a listing of other posts within a page?

I suspect you mean the latter, can you share the code you're using in your template to achieve it?

#2 in reply to: ↑ 1 @finomeno
2 years ago

Replying to dd32:

Hi @finomeno

Can you clarify what you mean by "blog roll"? Are you referring to the Blogroll functionality that lists other sites, or are you referring to embedding a listing of other posts within a page?

I suspect you mean the latter, can you share the code you're using in your template to achieve it?

Hi @dd32

I'm referring to the actual WP post loop. To display blog posts on a static front page, 10 per page, I'm using 'modules' - a sort of custom post type added by my theme, Binder PRO by Quadroideas. The .php template for the module responsible for showing blog posts is as follows:

<?php
/**
 * The template used for displaying Blog Modules content
 *
 */
?>

<?php 
$mod_id = get_the_ID();

// Get Blog Module Data
$blog_layout    = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_layout', true ) );
$blog_columns   = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_columns', true ) );
$blog_margins   = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_margins', true ) );
$blog_anim              = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_anim', true ) );
$blog_perpage   = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_perpage', true ) );
$show_nav               = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_show_nav', true ) );
$picker_method  = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_method', true ) );
$offset                 = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_offset', true ) );
$exclude                = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_exclude', true ) );
$blog_perpage   = $blog_perpage != '' ? $blog_perpage : get_option( 'posts_per_page' );

// Define Animations
$anim = $blog_layout == 'masonry' ? 'anim-grid' : '';

// Now, let's query for blog posts
global $paged;
$page_var = is_front_page() ? 'page' : 'paged';
$paged = (get_query_var($page_var)) ? get_query_var($page_var) : 1;
$offset = $paged == 1 ? $offset : ( $offset + ( $paged - 1 ) * $blog_perpage );
$args = array(
        'post_type' =>  'post',
        'posts_per_page' => $blog_perpage,
        'paged' => $paged,
        'offset' => $offset,
        'post__not_in' => explode( ',', $exclude )
 );

// Modify Query depending on the selected Show Method
if ( $picker_method == 'tax' ) {
        // Bring Selected Categories
        $sel_terms = esc_attr( get_post_meta( $mod_id, 'quadro_mod_blog_terms', true ) );
        if ( $sel_terms != '' ) {
                // Add tax query to query arguments
                $args['cat'] = $sel_terms;
        }
}
elseif ( $picker_method == 'format' ) {
        // Bring selected post formats
        $args = quadro_add_selected_formats( $mod_id, 'quadro_mod_blog_formats', $args );
}
elseif ( $picker_method == 'custom' ) {
        // Bring picked posts if there are some
        $args = quadro_add_selected_posts( $mod_id, 'quadro_mod_pick_blog', $args );
}

$wp_query = new WP_Query( $args );
?>

<section id="post-<?php the_ID(); ?>" class="quadro-mod type-blog clear blog-style-<?php echo $blog_layout; ?> masonry-margins-<?php echo $blog_margins; ?> <?php quadro_mod_parallax($mod_id); ?>">
        
        <?php // Apply function for inline styles
        quadro_mod_styles( $mod_id ); ?>
        
        <div class="inner-mod">
        
                <?php quadro_mod_title( $mod_id ); ?>
                <?php quadro_module_content(); ?>

                <?php if( $wp_query->have_posts() ) : ?>

                        <div class="blog-wrapper">

                                <div id="grid" class="<?php echo $anim; ?> anim-<?php echo $blog_anim; ?> blog-container blog-content blog-<?php echo $blog_layout; ?> blog-columns-<?php echo $blog_columns; ?>">
                                        
                                        <?php while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

                                                <?php // Define template part to be called for posts content
                                                if ( $blog_layout != 'masonry' ) {
                                                        get_template_part( 'content', $blog_layout );
                                                }
                                                else {
                                                        // We call the template part with include to facilitate the use of data.
                                                        include( locate_template('content.php') );
                                                } ?>

                                        <?php endwhile; ?>

                                </div>
                                
                                <?php if ( $show_nav == 'show' ) quadro_paging_nav( '<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>' ); ?>

                        </div>

                <?php else : ?>

                                <?php get_template_part( 'no-results', 'index' ); ?>

                <?php endif; // ends 'posts' loop ?>
                
                <?php wp_reset_postdata(); ?>

        </div>

</section>

#3 in reply to: ↑ 1 @finomeno
2 years ago

Replying to dd32:

Perhaps having a look at the site in question will give you a better idea. http://wonderwhite.ru - pagination does not work. http://wonderwhite.ru/test (exact copy of above page, but not set as home) - pagination works.

#4 @acidich2o
2 years ago

  • Keywords needs-patch added
  • Severity changed from normal to major

I'm having this same issue kind of. I noticed during 4.4.1 the issue that our static front page will not load our old news posts when I click page 2, 3, etc, while I can go to the category and it will. I updated to 4.4.2 and still same issue and I see many others still having issues all over the pages. News, hubs, latest reviews and etc. While it lists how many pages we have this is all I see at the bottom when I simply hover over page 2.... I don't think a URL for page 2 should be like this either, which I provided below.

linkstosite.com, which I'm keeping private /page/2?action=gp_ajax&ajaxnonce=958998651f&querystring&cats_new=0&menu_cats_new=0&pagenumber=1&type=news&postparentid&cats=1&posttypes=post&format=blog-standard&size=blog-standard-size&orderby=newest&dateposted=all&datemodified=all&perpage=8&menuperpage&offset=0&featuredimage=enabled&imagewidth=140&imageheight=140&hardcrop=1&imagealignment=image-wrap-left&titleposition=title-next-to-thumbnail&contentdisplay=excerpt&excerptlength=300&metaauthor=1&metadate=1&metacommentcount=1&metaviews&metafollowers&metacats=1&metatags&metahubcats&metahubfields&metahubaward&hubcats&hubfields&displaysiterating&displayuserrating&readmorelink=enabled&pagenumbers=enabled&authorid

Note: See TracTickets for help on using tickets.