WordPress.org

Ready to get started?Download WordPress

Forums

My Single Post Template for Custom Posts Displays All Posts (1 post)

  1. michaelwhawkes@gmail.com
    Member
    Posted 1 year ago #

    Hello,

    I have created single-our_team.php as my template for employee bios. I cannot figure out how to get it to display only the selected post rather than all posts. My code is below.

    Thanks,
    Michael

    <?php
    /*
    Single Post Template Name: Our Team Single Post
    Description: Single Post for Biographies
    */
    ?>

    <?php get_header(); ?>

    <div id="titlecontainer">
    <div id="titlebox">
    <div id="pagetitle">
    <h1><?php wp_title(''); ?></h1>
    </div>
    <div id="pageimage">
    <img src="<?php bloginfo('template_directory') ?>/assets/eb5s.png" />
    </div>
    </div>
    </div>

    <?php wp_meta(); ?>

    <div id="bodycontainer">

    <div id="pagecontent">

    <!-- Start the Loop. -->

    <?php $loop = new WP_Query(
    array( 'post_type' => 'our_team',
    'meta_key' => 'last_name',
    'orderby' => 'meta_value',
    'order' => 'ASC',
    )) ;
    ?>

    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <div class="bio-content">

    <table style="width:100%; margin:0; padding:0;">
    <tr>
    <td>

    <h2><?php echo get_post_meta($post->ID, "first_name", true); ?> <?php echo get_post_meta($post->ID, "middle_initial", true); ?> <?php echo get_post_meta($post->ID, "last_name", true); ?></h2>

    <p>Title: <?php echo get_post_meta($post->ID, "title", true); ?> | Office: <?php echo get_post_meta($post->ID, "office", true); ?> | Phone: <?php echo get_post_meta($post->ID, "phone_number", true); ?> | Email: ID, "email_address", true); ?>"><?php echo get_post_meta($post->ID, "email_address", true); ?></p>

    <p><?php echo get_post_meta($post->ID, "professional_profile", true); ?></p>

    </td>

    <td style="width:160px; vertical-align:middle" valign="middle"><div class="bio-image"><img align="middle" style="width:150px; vertical-align:middle" src="<?php echo get_post_meta($post->ID, "headshot", true); ?>" /></div>
    </td>
    </tr>

    </table>
    </div>
    <?php endwhile; ?>

    </div>

    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic