Frankly, this question shouldn’t exist, it has been answered hundreds of times across the web..
Im going to answer the most tricky part – query itself. Everything else is simple HTML
and PHP
. You can also find examples in link I provided below. If you can’t do PHP
and HTML
yourself, you shouldn’t ask this question and should be learning PHP
and HTML
(which is rather easy to pick up).
$args = array(
'post_type' => 'your-post-type-name',
'posts_per_page' => -1, //-1 means "get all posts", 5 would mean "get 5 posts" etc
'meta_query' => array(
array(
'key' => 'show_on_home_page',
'value' => true,
'compare' => 'IN', //Possible values: '=' '>' '<' etc
)
),
//In order to order by custom meta, you will need to make sure it exists
'meta_query' => array(
array(
'key' => 'home_page_posts_order_sequence',
'compare' => 'exists',
//Specifying type is VERY recommended, otherwise it might go wrong
'type' => 'numeric',
)
),
'orderby' => array( 'home_page_posts_order_sequence' => 'DESC' );
// DESC: descending order ASC: ascending order
);
$query_results = new WP_Query( $args );
Read more from here.