• Resolved yuranikolaev

    (@yuranikolaev)


    Hi there!

    I was very excited to see amp-next-page v1 in latest 1.5 update, so now I’m trying to build an infinite list of posts on the homepage (and archive pages as well)

    But there are some strange things happen

    This is the url with sample https://wideawake.ru
    (upd: you’ll have to toggle device in the inspector since there is a mobile detect)

    Some details

    WP 5.x
    AMP 1.5.1

    Plugins (after deactivating all unnecessary): ACF Pro, CPT UI, AMP, Classic Editor, WP-PostViews, Co-authors, Custom Post Type Permalinks

    amp-next-page is the last element of the body

    no errors in console or wp debug log

    —-

    So, I have a homepage with custom loop

    <?php 
    $paged = (get_query_var( 'page' )) ? get_query_var( 'page' ) : 1;
    
    $args = array(
    	'post_type' => array('news', 'promo', 'tp', "b", 'live', 'podcast'),
    	'post_status' => 'publish',
    	'posts_per_page' => 10,
    	'paged' => $paged,
    	
    	'meta_query'=> array(
    		array(
    			'key'     => 'frontpage',
    			'value'   => true,
    			'compare' => '=',
            ),
    	),
    ); 
    
    $custom_query = new WP_Query($args);
    if ($custom_query->have_posts() ) : ?>
    	<div class="article-list">
    		<?php while($custom_query->have_posts() ) : $custom_query->the_post(); ?>
    			
    			<?php get_template_part($route->post_card); ?>
    
    		<?php endwhile; ?>
    	</div>
    	<?php wp_reset_postdata(); ?>
    <?php endif; ?>

    The pagination works fine. I tested it by manually type urls (wideawake.ru/page/2, wideawake.ru/page/3 etc.) in browser

    There is simple wp function get_next_posts_page_link(), which is also works fine and get me the url of the next page (home_url/page/2, etc)

    My amp-next-page (which is the last element of the body) is

    <?php 
    if(is_front_page()) :
            $nextLink = array(get_next_posts_page_link());	
    ?>
    
    <amp-next-page deep-parsing="true">
      	<script type="application/json">
      		[
      			{
    				"image": "<?php echo content_url(); ?>/uploads/2020/03/prophecy_interior_2_1.jpg", 
    				"title": "Next page",
    				"url": "<?php print_r($nextLink[0]); ?>"
    			}
      		]
      	</script>
      </amp-next-page>
    <?php endif; ?>

    Everything should work (I supposed), but

    1. Some pages are duplicate;
    2. Image disappears on some pages (including thouse are duplicate), but still present in the page source;
    3. URLs strange behaviour on scroll down the page (page/2 -> homepage -> page/2 -> page/3 -> homepage -> page/3 etc.);
    4. There is an unexpected 8px margin on the next page body;

    You can see all this happens in the sample

    What did I already tried

    1. deactivating all plugins
    2. raw json with links in template
    3. src attr with json object
    4. according to amp docs combine them both
    5. different browsers and devices
    6. disabling all other stuff like fixed footer, header on so on

    gets the same result

    btw: same strange things happen with single template

    is this a general amphtml issue, something with wp amp or am I doing something wrong?

    stuck
    help
    thanx )

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Amp-next-page v1 strange behaviour’ is closed to new replies.