php - how to query a post based on previous page post ID

sorry I probably didn't word the question properly. So i'll describe what im trying to achieve. I have Page A

sorry I probably didn't word the question properly. So i'll describe what im trying to achieve.

I have Page A that has a slider of the different posts. When you click on one it redirects you to the full article(Page B) which also has the same slider. Page B where the full article is has the "next" and "prev" buttons to cycle through the other available posts. For example there are #10 posts in Page A slider, #5 is chosen so this should redirect to the full article of #5 on Page B. And this is where my issues lie.

The slider and query for both page A and B is like this:

<?php 
    $args = array (
        'posts_per_page' => -1,
        'post_type' => 'blog'
    );
    $blog_list = new WP_Query($args);
?>
<?php if( $blog_list->have_posts() ):?>
<?php while( $blog_list->have_posts() ) : $blog_list->the_post();?>

<li class="column swiper-slide">
    <div>
        <?php echo '<a href="'. get_permalink($post->ID) .'">'; ?>
    </div>
</li>
<?php endwhile;?>
<?php endif; ?>
<?php wp_reset_query();

I believe It is a query issue because the URL bar of page B displays the correct link but page B article shows #1 but it should show #5. How should i adjust the query? or if someone could let me know what part of the wordpress doc i should be reading up that would be great as im actually new to this.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745632685a4637203.html

相关推荐

  • php - how to query a post based on previous page post ID

    sorry I probably didn't word the question properly. So i'll describe what im trying to achieve. I have Page A

    22天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信