admin管理员组文章数量:1404586
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.
本文标签: meta queryHow to mark only one post as Featured post
版权声明:本文标题:meta query - How to mark only one post as Featured post? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744840127a2627873.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论