I created an archive-sticky.php the place I added the code beneath to point out all sticky posts in a single single web page with pagination as there will probably be 100s of sticky posts within the coming days.
Now, this code shows the content material because it ought to however the pagination isn’t displaying/working. The place am I going incorrect? I’ve learn up 10s of queries right here however nothing appears to unravel my downside.
The pagination is working for different pages although.
<?php get_header();
/*
Template Identify: Archives Sticky
*/
?>
<?php
$the_query = new WP_Query( array(
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'publish',
'post_status' => 'publish',
'posts_per_page' => 3,
'post__in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1,
));
?>
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>Sticky Featured posts</h2>
<?php if ( $the_query->have_posts() ) : ?>
<?php whereas ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</div>
<?php endwhile; ?>
<?php if (function_exists("pagination")) {
pagination($custom_query->max_num_pages);
} ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php __('No Information'); ?></p>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Here is how the features.php appears like:
perform pagination($pages="", $vary = 4)
{
$showitems = ($vary * 2)+1;
world $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
world $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class="pagination"><span>Web page ".$paged." of ".$pages."</span>";
if($paged > 2 && $paged > $vary+1 && $showitems < $pages) echo "<a href="https://wordpress.stackexchange.com/questions/410787/".get_pagenum_link(1)."">« First</a>";
if($paged > 1 && $showitems < $pages) echo "<a href="".get_pagenum_link($paged - 1)."">‹ Earlier</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$vary+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class="present">".$i."</span>":"<a href="".get_pagenum_link($i)."" class="inactive">".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href="".get_pagenum_link($paged + 1)."">Subsequent ›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href="".get_pagenum_link($pages)."">Final »</a>";
echo "</div>n";
}
}