I am trying to display an post to my home page based on a selection. What I mean is in the backend I have a custom post that has a metabox labeled Assign to Home with a drop down that has a selection of Yes or No. What I am trying to do is when a custom post has a selection of Yes it will be displayed on the home page. When a selection says No it will not be displayed.
The code below is what I am trying to use to call my post. the Post Type and meta key are both correct but when I try and display my post I get an array.
home page
<?php function posts_draft($meta_values) {
$args_draft = array(
'numberposts' => 3,
'post_type' => 'fe', // set you custom post type
'meta_key' => '_cmb_homeDisplay',
'meta_value' => $meta_values,
);
$my_posts_draft = get_posts( $args_draft );
$posts_draft = get_posts($my_posts_draft);
return $posts_draft;
}
{
echo posts_draft('yes');}
?>
<?php if ( $fleet->have_posts() ) : while ( $fleet->have_posts() ) : $fleet->the_post(); ?>
<div class="fleetBox">
<img src="https://wordpress.stackexchange.com/questions/172557/<?php echo get_post_meta($post->ID,"_cmb_limoThumbnail", true); ?>" />
<ul>
<li><h3><?php the_title( '' ); ?></h3></li>
<li><h4>Luxury <?php echo get_post_meta($post->ID, '_cmb_limo_select', true); ?></h4></li>
<li><a href="<?php echo get_permalink(); ?>">More Details</a></li>
</ul>
</div>
<?php endwhile; endif; ?>
I know this may not be that helpful because its a mall amount of code but this is what I am using to display my drop down. This code is a small snippet in the full custom post type that I am using.
The post Type being used for this snippet is fe
and the meta key that gets assigned to all of my prefix id is cmb
array(
'name' => 'Display Home',
'desc' => 'Select an option',
'id' => $prefix . 'homeDisplay',
'type' => 'select',
'options' => array(
'custom' => __( 'Select...', 'cmb' ),
'standard' => __( 'Yes', 'cmb' ),
'none' => __( 'No', 'cmb' ),
),
'default' => 'custom',
),