0

I have the code below on my homepage to list posts from a specific category, then a second piece to list posts from across the site.

The problem I'm having is that there is some sort of weirdness going on, where I can't scroll to the bottom of the page. When I reach the bottom the page instantly jumps up.

This behaviour happens in safari, but also FF, however in the latter it only happens when the web developer tools are open.

First list

<ul>
            <?php
                global $post;
                $tmp_post = $post;
                $args = array( 'numberposts' => 3, //'offset'=> 1,
                 'category' => 67 );
                $myposts = get_posts( $args );
                foreach( $myposts as $post ) : setup_postdata($post); ?>
                    <li>
                        <article class="front-page-summary">
                            <a href="<?php the_permalink(); ?>">
                                <?php echo the_post_thumbnail('homepage-thumb'); ?>                     
                                <div class="post-details-wrapper">
                                    <h3><?php the_title(); ?></h3>
                                    <?php the_excerpt(); ?>
                                </div>
                            </a>
                        </article>  
                    </li>
                <?php endforeach; ?>
                <?php $post = $tmp_post; ?>
</ul>

Second list

<h2>Latest Posts</h2><hr class="section-divider">
    <span class="subheading">My latest thoughts on travel, gear, and everything else</span>
        <?php
        global $post;
        $tmp_post = $post;
        $args = array( 'numberposts' => 3);
        $myposts = get_posts( $args );
        foreach( $myposts as $post ) : setup_postdata($post); ?>

        <div class="latest-post-list">
            <span class="meta"><?php the_date(); ?></span> / <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> / <span class="meta"><?php the_category(', '); ?></span>
        </div>

        <?php endforeach; ?>
        <?php $post = $tmp_post; ?>
        <div class="clear"></div>

The problem does not occur if I remove the 'first list' code, which leads me to believe that there is an error there. Can you see it?

3
  • 1
    This sounds like a client-side issue - disable JavaScript & test again. – TheDeadMedic May 17 '16 at 9:49
  • 1
    If the behaviour is different across browsers it's probably about the interaction between html and css, not about wordpress. – cjbj May 17 '16 at 9:50
  • Ah right. Yes i can scroll to the bottom if I disable javascript. None of the code posts calls for any JS though, so I don't know what's triggering it. – C-M May 17 '16 at 9:52
0

It was Stellar parallax. Here is the offending code:

// Stellar parallax var $ = jQuery.noConflict(); $(function(){ $.stellar({ horizontalScrolling: false, verticalOffset: 40 }); });

I now need to go away and figure out what in this code was giving me the problem.

Thanks for the prompts of where to look.

-3

Use wp_reset_query(); in the end of the loop

3
  • 3
    Please explain why OP should use wp_reset_query() and why not wp_reset_postdata() ? – Sumit May 17 '16 at 9:54
  • I've now added wp_reset_query() at the end of the two loops. I suppose that (re)sets things up for the next call, if there is one on the page. – C-M May 17 '16 at 10:06
  • 1
    This really has nothing to do with how Wordpress generates the html. It is a browser issue. – cjbj May 17 '16 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.