• 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; ?>

Viewing 1 replies (of 1 total)
  • Thread Starter HunterHawley

    (@hunterhawley)

    Never mind, figured it out, sorry to bother! I didn’t need the query after all. The standard <?php if ( have_posts() ): while ( have_posts() ): the_post(); ?> will do in this case.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type Displaying All Posts’ is closed to new replies.