Custom Post Type Displaying All Posts
-
I am creating a custom post type, but when I create the single-customer.php file, and navigate to one of my posts, it displays them all! How do you go about making it so that only the post you click the link on, on the front page, displays on the single-customer.php template?
Is there something you have to put in the query? Here is the main code block I am using.
<?php
$args = array(
‘post_type’ => ‘customer’,
‘posts_per_page’ => 1
);$the_query = new WP_Query( $args );
?>
<?php if ( have_posts() ): while ( $the_query -> have_posts() ): $the_query -> the_post(); ?>
<h1><?php the_title(); ?></h1>
<p>Contact Name: <?php the_field( ‘contact_name’ ); ?></p>
<p>Phone Number: <?php the_field( ‘phone_number’ ); ?></p>
<p>E-Mail Address: “><?php the_field( ‘e-mail_address’ ); ?></p>
<p>Account Type: <?php the_field( ‘account_type’ ); ?></p>
<p>Contract Sign Date: <?php the_field( ‘contract_sign_date’ ); ?></p>
<p>Account Notes: <?php the_field( ‘account_notes’ ); ?></p><?php endwhile; endif; ?>
- The topic ‘Custom Post Type Displaying All Posts’ is closed to new replies.