If you want to use post meta for setting which posts are displayd on the front page, then I would recommend saving the setting with a separate meta_key. So instead of pushing it to the your_fields
save it with its own key.
This means modifying your metabox content to have something like this,
<input type="checkbox" name="show_on_front_page" value="true"
Please modifiy your metabox saving box also accordingly.
Then you should be able to use the get_posts
like so,
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'cv',
'meta_key' => 'show_on_front_page',
'meta_value' => 'true'
));
But just yesterday I saw a comment by Mr. Tom J Nowell on some other thread, that this is rather inefficient way of setting front page posts. On a larger site this could, in the worst case scenario, grind your site’s server to a halt.
You would be better off using a (private) custom taxonomy to which you would assign posts you want to show on the front page. Getting posts with a certain taxonomy from the database is faster and more efficient way of doing things.
From Mr. Nowell’s blog, https://tomjn.com/2018/03/16/utility-taxonomies/
Set up custom taxonomy,
function tomjn_utility_taxonomy() {
$args = array(
'label' => __( 'Internal Markers', 'tomjn' ),
'public' => false,
'rewrite' => false,
'show_ui' => true, // you'd need this if you want to show the taxonomy metabox on the post edit screen
);
register_taxonomy( 'utility', 'post', $args );
}
add_action( 'init', 'tomjn_utility_taxonomy', 0 );
Automate publishing to front page,
function tomjn_auto_add_to_home( $post_id ) {
wp_set_object_terms( $post_id, 'show_on_homepage', 'utility', true );
}
add_action( 'publish_post', 'tomjn_auto_add_to_home' );
adjust the homepage query
function tomjn_only_show_home( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'utility', 'show_on_homepage' );
}
}
add_action( 'pre_get_posts', 'tomjn_only_show_home' );
Please refer to the blog post for more detailed explanation.