As you said in a comment that you want to make it dynamic and wants to call anywhere of the website. Then in WP the best option is to use the shortcode. You can create a short code and call it where ever you want. One thing you can update it’s design as per your need, I am sharing a way to create a short code for the CPT.
/**
* Register all shortcodes
*
* @return null
*/
function register_shortcodes() {
add_shortcode( 'produtos', 'shortcode_mostra_produtos' );
}
add_action( 'init', 'register_shortcodes' );
/**
* Produtos Shortcode Callback
*
* @param Array $atts
*
* @return string
*/
function shortcode_mostra_produtos( $atts ) {
global $wp_query,$post;
$atts = shortcode_atts( array(
'line' => ''
), $atts );
$loop = new WP_Query( array(
'posts_per_page' => 200,
'post_type' => 'produtos',
'orderby' => 'menu_order title',
'order' => 'ASC',
'tax_query' => array( array(
'taxonomy' => 'linhas',
'field' => 'slug',
'terms' => array( sanitize_title( $atts['line'] ) )
) )
) );
if( ! $loop->have_posts() ) {
return false;
}
while( $loop->have_posts() ) {
$loop->the_post();
echo the_title();
}
wp_reset_postdata();
}
I have created a shortcode for the products to display the product list.
Now you can add [produtos] on the wp backend page/post and after saving this will display the produts title (as i only echo the title) on the front end.
For more reference about the shortcode API you can follow this article SHORTCODE API
Try this. I think this will help you. Let me know if you will face any issue here.
Enjoy!!:)