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 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.

    global $post;

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

    if ( $myposts ) {
        foreach ( $myposts as $post ) : 
            setup_postdata( $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.

, , , leonardeveloper 2 years 2020-01-13T08:39:30-05:00 0 Answers 77 views 0

Leave an answer