• Hello everyone! First of all, sorry me if my English isn’t very clear but it’s not my native language, so I’ll try to explain my problem as detailed as possible. My site runs with WordPress 4.3.1 and I’m trying to modify the presentation of pagination for older posts on the index page.

    The layout has some static text on the index.php page and display 9 entries by default. Like this:

    TITLE
    TEXT TEXT TEXT TEXT
    TEXT TEXT TEXT TEXT
    TITLE
    POST POST POST
    POST POST POST
    POST POST POST
    TITLE
    TEXT TEXT TEXT TEXT

    The problem is: when the user click on “Older entries” button and the site goes to http://example/page/2, the new page display again the text up and down the posts. There is a way to display that text only on index or change the “pagination” style of the posts to show only older entries?

    Thanks in advance! =)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Hi Dot22!

    One way of doing that could be by using the is_paged() conditional. Depending on how your theme is structured you will have to make a few changes. The best, and recommended method would be to create a child theme and make changes that way.

    Thread Starter Dot22

    (@dot22)

    Hello Jose,

    Thanks for your reply. This is the code of my index.php page:

    <?php get_header(); ?>
    <div class="content-path">Some text here</div>
    		<div class="container"><br />
    			<h2>News</h2>
                <?php $c = 0; if ( have_posts() ) : ?>
                <?php query_posts($query_string . '&cat=1'); ?>
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); $c++; ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
                    <?php if( $c == 2 ) :?>
    <div style="margin: -50px auto 10px;"><hr /></div>
    <?php $c = 0;
    endif;?>
    			<?php endwhile; ?>
    			<?php custom_content_nav( 'nav-below' ); ?>
    		<?php else : ?>
    			<?php if ( current_user_can( 'edit_posts' ) ) :
    				// Show a different message to a logged-in user who can add posts.
    			?>
    		<div style="text-align: center; font-weight: bold;"><?php _e( 'Nothing found.', 'custom' ); ?></div>
    			<?php else :
    				// Show the default message to everyone else.
    			?>
    		<div style="text-align: center; font-weight: bold;"><?php _e( 'Nothing found.', 'custom' ); ?></div>
    				<div style="text-align: center; font-weight: bold;"><?php _e( 'Nothing found.', 'custom' ); ?><br />
    					<?php get_search_form(); ?>
    				</div><!-- .entry-content -->
    			<?php endif; // end current_user_can() check ?>
    		<?php endif; // end have_posts() check ?>
    <div class="content-path2">More text here</div>
    <div align="right"><a href="#top">up? <span class="fa fa-arrow-circle-o-up fa-lg"></span></a></div></div>
    <?php get_footer(); ?>

    How can I use the is_paged() conditional? Thanks again!

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    The most simplest way of using it is:

    if ( !is_paged() ):
      // code that will only show on the front page or
      // page 1 or an archive
    endif;

    The codex page for it:
    https://codex.wordpress.org/Function_Reference/is_paged

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post pagination on index page’ is closed to new replies.