The Single Posts template controls the layout of individual posts on your site. When you make a change to this template, the change will reflect on all your posts, ensuring a consistent experience for visitors browsing through your blog. This guide will show you how to customize the Single Posts template.
- Duplicate the
single.php
file in your template and rename it likesingle-{post_type}.php
(eg.single-movie.php
) (this is best way only you need to copy and paste single.php code). - Flush the permalinks from WordPress
single-movie.php
<?php $args = array( 'post_type' => 'services', 'posts_per_page' => 20 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="services-items">
<?php the_title();
if ( has_post_thumbnail( $post->ID ) ) {
echo '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( $post->post_title ) . '">';
echo get_the_post_thumbnail( $post->ID, 'thumbnail' );
echo '</a>'; }
?>
</div>
<?php endwhile; ?>
<?php $query = ['post_name' => 'movie', 'post_status' => 'publish']; $movieQuery = new Wp_Query($query); while($movieQuery->have_posts()){ $movieQuery->the_post(); $title = the_title(); $date = get_the_date(); $thumbPath = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); $thumb = $thumbPath[0]; } ?>