You can create a shortcode and add it in any page you want.
This code will register your custom shortcode:
add_action( 'init', 'register_custom_shortcodes' );
function register_custom_shortcodes(){
add_shortcode( 'my-custom-shortcode', 'display_movies' );
}
This code will be responsible for the content that will be displayed wherever you place the shortcode:
function display_movies(){
ob_start();
//Your code here to display your custom post type posts
return ob_get_clean();
}
You can place the above functions to your functions.php
Then inside the function display_movies() you can run a WP_Query to display your posts. You can read about all the arguments that WP_Query takes here: https://developer.wordpress.org/reference/classes/wp_query/
A sample code to display your custom post type posts would be:
$args = array(
'posts_per_page' => 10, //Number of Posts
'post_type' => 'movie', //Replace with you custom post type slug
'post_status' => 'publish',
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<div class="movies-wrapper">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
?>
<div class="movie-item">
<?php the_title(); ?>
<?php
//Maybe display a custom field
echo get_post_meta( get_the_ID(), 'your_custom_meta_key', true );
?>
</div>
<?php
}
echo '</div>';
}
else {
// no posts found
}
// Restore original Post Data
// This code is important do not forget to place it
wp_reset_postdata();
wp_reset_query()
You can place the above code in your display_movies() function.
Once you have created your shortcode you can place it any page you want as following:
[my-custom-shortcode][/my-custom-shortcode]
As for the search functionality it becomes a bit more complicated. It depends on the filters you might want to be used, if you want an AJAX search. In most cases you will still use the WP_Query to achieve a search functionality.