0

My featured articles have been built with the following query:

$featured_posts = new WP_Query(  array(  'post__not_in' =--> get_option( 'sticky_posts' ),
 'meta_key' => is_featured',
 'meta_value' => 1
 ) );

How can I detect if my current (singlepage) article is featured or not? I obviously need to query whether it has is_featured flag, but how do I build this query?

Many thanks.

1 Answer 1

1

$is_featured_post = get_post_meta(get_the_ID(), 'is_featured', TRUE);

This will return the value in the variable and you can check your condition.

Instead of get_the_ID(), you can use any post ID. Refer the documentation here: get_post_meta.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.