• i’m using this below code to display the posts:

    // My post arguments
    $my_post_args = array(
    	'post_type' => 'property',
    	'posts_per_page' => 10,
    	'paged' => $paged,
    	'post_status' => array( 'pending', 'draft', 'publish', 'future' ),
    	'author' => $current_user->ID
    );
    
    $my_properties_query = new WP_Query( $my_post_args );
    if ( $my_properties_query->have_posts() ) :
    	//
    		while ( $my_properties_query->have_posts() ) :
    				$my_properties_query->the_post();
    
    		[[THE CODE HERE: HOW TO CHECK IF MY POST IS FEATURED POST OR NOT??]]
    
    		endwhile;
    				wp_reset_query();
    	//
    	else:
    		alert( __('Note:','framework'), __('No Properties Found!','framework') );
    endif;

    How to check if every post is featured or not?

    Thanks for help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    A “featured post” is not a default part of WP core.

    Your question presumes that they exist, like they are already somewhere in your site, marked as Featured.

    But the capability to mark a post as featured is not part of WP core.

    So since it is not part of WP core, I cannot tell you how to check.

    One can create “Featured” posts by assigning a category/taxonomy to them, etc but that is something that has to be setup in your site.

    So until you can explain how a post is Featured in your site, I cannot explain how to check for them.

    If you mean sticky posts, you can use is_sticky() to check:

    while ( $my_properties_query->have_posts() ) : $my_properties_query->the_post();
      if ( is_sticky() ) :
        ... do something ...
      else :
        ... do something else ...
      endif;
    endwhile;
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to check if the post is featured or not?’ is closed to new replies.