WordPress.org

Ready to get started?Download WordPress

Forums

Previous/Next Page Links not Working (2 posts)

  1. nellygrl
    Member
    Posted 5 months ago #

    For some reason, when you click "Previous Posts" on my wordpress blog, the page URL changes, but the first ten posts are displayed again.

    You can see the issue here: http://onedirectionconnection.com/ and then page two http://onedirectionconnection.com/page/2/#sthash.0SQiq9AP.dpbs (that's another thing - I'm not sure why that code is being added at the end of the following page's URL)...

    I tried disabling all my plugins but it didn't fix the issue.

    Anyway, here is the code I'm using for my front page template saved in a file called front-page.php. I use two queries - one to display the entire latest post, and then another to display the other latest post excerpts in reverse chronological order. When one clicks previous posts, in a perfect world, the posts with excerpts would change - but they stay the same.

    <?php
    /*
    Template Name: Splash Page
    */
    
    get_header(); ?>
    
        <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
                <div class="section-container">
                    <h1 class="section-title">Latest News</h1>
                </div>
                <?php $my_query = new WP_Query('showposts=1'); ?>
                <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
                <h1 class="entry-title bottommargin big">
                    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
                </h1>
                <div class="entry-content">
                    <?php the_content(); ?>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <footer class="row no-margin">
                            <div class="col-md-3 meta-entry">
                                Author: <br>
                                <?php the_author_link(); ?>
                            </div>
                            <div class="col-md-3 meta-entry">
                                Posted On:<br>
                                <?php the_time('F j, Y'); ?>
                            </div>
                            <div class="col-md-3 meta-entry">
                                Categorized:<br>
                                <?php echo get_the_category_list(', '); ?>
                            </div>
                            <div class="col-md-3 meta-entry-right">
                                Discussion:<br>
                                <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a>
                            </div>
                        </footer>
                    </div>
                </div>
                <?php endwhile; ?>
                <div class="section-container">
                    <h1 class="section-title">More News</h1>
                </div>
                <?php
    
                    $custom_query = new WP_Query(array(
                        'posts_per_page' => 10,
                        'offset' => 1,
                        'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
                    ));
    
                ?>
                <?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>
                <div class="row topmargin">
                    <div class="col-md-3 no-padding center">
                        <?php the_post_thumbnail('thumbnail', array('class' => 'img-thumbnail img-responsive')); ?>
                    </div>
                    <div class="col-md-9">
                        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                            <header class="entry-header">
                                <h1 class="entry-title">
                                    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                                </h1>
                            </header><!-- .entry-header -->
    
                            <div class="entry-content">
                                <?php the_excerpt(); ?>
                                <?php
                                    wp_link_pages( array(
                                        'before' => '<div class="page-links">' . __( 'Pages:', 'professional1d' ),
                                        'after'  => '</div>',
                                    ) );
                                ?>
                            </div><!-- .entry-content -->
                        </article><!-- #post-## -->
    
                        <?php
                            // If comments are open or we have at least one comment, load up the comment template
                            if ( comments_open() || '0' != get_comments_number() )
                                comments_template();
                        ?>
                    </div>
                </div>
                <footer class="row no-margin">
                    <div class="col-md-3 meta-entry">
                        Author: <br>
                        <?php the_author_link(); ?>
                    </div>
                    <div class="col-md-3 meta-entry">
                        Posted On:<br>
                        <?php the_time('F j, Y'); ?>
                    </div>
                    <div class="col-md-3 meta-entry">
                        Categorized:<br>
                        <?php echo get_the_category_list(', '); ?>
                    </div>
                    <div class="col-md-3 meta-entry-right">
                        Discussion:<br>
                        <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a>
                    </div>
                </footer>
    
                <?php endwhile; // end of the loop. ?>
    
                <div class="center">
                    <?php posts_nav_link(); ?>
                </div>
    
            </main><!-- #main -->
        </div><!-- #primary -->
    
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Any help with this would be GREATLY appreciated. Thank you.

  2. nellygrl
    Member
    Posted 5 months ago #

    I thought maybe I'd coded my loops wrong? Does anyone have any input on this?

Reply

You must log in to post.

About this Topic