WordPress.org

Ready to get started?Download WordPress

Forums

Pagination on Single.php (1 post)

  1. greydog
    Member
    Posted 1 year ago #

    I have a single.php which display content from the post as expected. Below that, I have the following code pulling out posts which are related (in the same category).

    <?php
    global $post;
    $cat_ID=array();
    $categories = get_the_category(); //get all categories for this post
    foreach($categories as $category) {
    array_push($cat_ID,$category->cat_ID);
    }
    $args = array(
    'orderby' => 'date',
    'order' => 'DESC',
    'post_type' => 'post',
    'numberposts' => 10,
    'post__not_in' => array($post->ID),
    'category__in' => $cat_ID
    );
    $cat_posts = get_posts($args);
    if ($cat_posts) {
    
    echo '<section id="related" class="grid_10 prefix_1 suffix_1 alpha omega">';
    echo '<h2>Related</h2>';
    foreach ($cat_posts as $cat_post) {
    ?>
    
    //STUFF HERE
    
    <?php  } echo '</section><!-- related -->'; } ?>

    Currently it displays 10 posts.

    My question is: Is it possible to paginate this (single.php) page so that I can display the next 10 posts?

    Thanks for helping.

Topic Closed

This topic has been closed to new replies.

About this Topic