I do know this can be a duplicate query. However to touch upon present query, I dont have sufficient factors.
So right here we go….
Pagination is just not engaged on customized question inside a customized dwelling web page template.
The answer (which labored for a lot of others) under is taken from one other query.
Easy methods to repair pagination for customized loops?
<div class="most-popular type-1">
<h3 class="section-headline"><?php _e('Most Widespread','themename'); ?></h3>
<div class="widget-articles clearfix">
<?php
$mostpopular_args=array(
'post_type' => 'put up',
'orderby' => 'meta_value_num',
'meta_key' => 'view_count',
'posts_per_page' => '10',
);
$mostpopular_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
?>
<?php
$mostpopular_pick = new WP_Query($mostpopular_args);
// Pagination repair
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $mostpopular_pick;
?>
<?php if($mostpopular_pick->have_posts() ): ?>
<?php whereas($mostpopular_pick->have_posts()): $mostpopular_pick->the_post(); ?>
<article class="widget-article">
<a href ="<?php the_permalink(); ?>">
<div class="widget-article-thumb">
<?php if(has_post_thumbnail()){ ?>
<?php $page_thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'featuredsmall'); ?>
<img src="<?php echo $page_thumb[0]; ?>" alt="" />
<?php } ?>
</div>
</a>
<div class="widget-content-wrapper">
<h3 class="widget-article-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div>
<div class="only-count">
<div class="icon icon-share-alt" aria-hidden="true"></div>
<?php echo do_shortcode('[mashshare shares="true" buttons="false"]'); ?>
<div class="share-text">SHARES</div>
</div>
</article>
<?php endwhile; ?>
<?php endif; ?>
<?php
wp_reset_postdata();
// Customized question loop pagination
previous_posts_link( 'Older Posts' );
next_posts_link( 'Newer Posts', $mostpopular_pick->max_num_pages );
// Reset foremost question object
$wp_query = NULL;
$wp_query = $temp_query;
?>
</div>
</div>
Nevertheless this isn’t working for me, I dont know why. Is there any exterior issue?
Between that is my whole customized dwelling web page template.
<?php
/*
Template Title: House Web page
*/
?>
<?php get_header(); ?>
<div class="main-content col-xs-12" position="main">
<div class="row">
<?php get_sidebar('abovethefold'); ?>
</div>
<div class="row">
<?php get_sidebar('homecolumnone'); ?>
<div class="homecolumntwo-sidebar col-sm-4 col-md-5">
<div class="most-popular type-1">
<h3 class="section-headline"><?php _e('Most Widespread','themename'); ?></h3>
<div class="widget-articles clearfix">
<?php
$mostpopular_args=array(
'post_type' => 'put up',
'orderby' => 'meta_value_num',
'meta_key' => 'view_count',
'posts_per_page' => '10',
);
$mostpopular_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
?>
<?php
$mostpopular_pick = new WP_Query($mostpopular_args);
// Pagination repair
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $mostpopular_pick;
?>
<?php if($mostpopular_pick->have_posts() ): ?>
<?php whereas($mostpopular_pick->have_posts()): $mostpopular_pick->the_post(); ?>
<article class="widget-article">
<a href ="<?php the_permalink(); ?>">
<div class="widget-article-thumb">
<?php if(has_post_thumbnail()){ ?>
<?php $page_thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'featuredsmall'); ?>
<img src="<?php echo $page_thumb[0]; ?>" alt="" />
<?php } ?>
</div>
</a>
<div class="widget-content-wrapper">
<h3 class="widget-article-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div>
<div class="only-count">
<div class="icon icon-share-alt" aria-hidden="true"></div>
<?php echo do_shortcode('[mashshare shares="true" buttons="false"]'); ?>
<div class="share-text">SHARES</div>
</div>
</article>
<?php endwhile; ?>
<?php endif; ?>
<?php
wp_reset_postdata();
// Customized question loop pagination
previous_posts_link( 'Older Posts' );
next_posts_link( 'Newer Posts', $mostpopular_pick->max_num_pages );
// Reset foremost question object
$wp_query = NULL;
$wp_query = $temp_query;
?>
</div>
</div>
</div> <!-- finish sidebar -->
<?php //get_sidebar('homecolumntwo'); ?>
<?php get_sidebar('homecolumnthree'); ?>
</div>
</div> <!-- finish main-content -->
<?php get_footer(); ?>
Any assist could be extremely appreciated 🙂 Thank You <3