custom post type single page

I have a custom post type called “listing” and am using a template called content-own.php to display all of my listings. In that page I am using:

<a href=”<?php echo str_replace( home_url(), ”, get_permalink($post->ID) ); ?>

to get a link to each single listing. When I click that link it shows all of the listings on that page instead of just that single listing. The template I am using for the single listing is single-listing.php which directs to content-listing.php. There I have:

<article id=”post-<?php the_ID(); ?>” <?php post_class($post-
>post_name); ?>>
<div class=”container mainPage”>
<div class=”row”>
<div class=”entry-content col-sm-9″>
<?php $args = array( ‘post_type’ => ‘listing’);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class=”col-6 col-sm-6 box no-gutters”>
<?php sd_template_post_thumbnail();
the_title(‘<h2>’, ‘</h2>’); ?>
<span><?php the_field(‘price’); ?></span>
<span><?php the_field(‘description’); ?></span>
<span><?php the_field(‘style’); ?></span>
<span><?php the_field(‘design’); ?></span>
<?php endwhile; ?>
</div><!–entry-content col-sm-9–>
<div class=”sideContact col-sm-3″>
<?php get_sidebar(); ?>
</article><!– #post-<?php the_ID(); ?> –>

So I’m not sure if I am doing something incorrectly with the way my templates are set up or with the loop on the content-listing.php page. Hopefully I explained this correctly, I’m fairly new to custom post types and WordPress.

Read more here:: custom post type single page

Leave a Reply

Your email address will not be published. Required fields are marked *