meta query - How to mark only one post as Featured post?

Am working on a blog page and I want to have a featured post as a banner. I have no idea how can I make only one post ca

Am working on a blog page and I want to have a featured post as a banner.

I have no idea how can I make only one post can be marked as the "Featured" so if another post is marked as "Featured" it removes the old post from showing as featured.

I've tried using ACF (Advance Custom Field) checkbox to mark featured posts but my approach is incorrect. Here is my code.

  <?php
    global $post;

    $myposts = get_posts( array(
        'posts_per_page'   => 1,
        'order'            => 'DESC',
        'numberposts'      => 1,
    ) );

    if ( $myposts ) {
        foreach ( $myposts as $post ) : 
            setup_postdata( $post ); 
            if(get_field('featured_post')):
    ?>

Once I marked the other posts featured nothing shows up.

Planning to follow this approach but I have no idea on how to remove the old featured posts.

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

相关推荐

  • meta query - How to mark only one post as Featured post?

    Am working on a blog page and I want to have a featured post as a banner. I have no idea how can I make only one post ca

    2天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信