WordPress.org

Ready to get started?Download WordPress

Forums

Pagination global $post (4 posts)

  1. chrisonga
    Member
    Posted 1 year ago #

    Hello everyone,
    Having trouble getting my head around Pagination.
    I looked at pother similar posts but can't seem to understand what to do. Have the loop below getting the latest 10 posts on the news page, but want to add pagination at the bottom to retrieve the next 10 on the next page. footballismore.org/medien/news/

    Code as follows:

    <?php global $post;
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$tmp_post = $post;
    	$args = array( 'category__in' => 7, 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC', 'paged'=> $paged );
    	$myposts = get_posts( $args );
    	foreach( $myposts as $post ) : setup_postdata($post); ?>
        <div class="news">
        <?php the_post_thumbnail(); ?>
    	<h2><?php the_title(); ?></h2>
        <div id="date" class="sidebar">
        <em><?php the_time('F j, Y') ?></em>
    	</div><!--close date-->
        <?php the_content(__('Read more...','en_US'), $strip_teaser, $more_file); ?>
        </div>
        <?php endforeach; ?>
    	<?php $post = $tmp_post; ?>

    I know I need to add the links or page numbers but not sure how or even if this above code is correct. Thanks in advance for any help!

  2. sulaphen_mani
    Member
    Posted 1 year ago #

    hi just these any ideas you'll get tryu this
    https://codex.wordpress.org/Pagination

  3. sulaphen_mani
    Member
    Posted 1 year ago #

  4. sulaphen_mani
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic