trailrunner89
trailrunner89

Reputation: 99

Viewing custom Post types

I have successfuly looped through my custom post types and they are showing on my site, I was wondering if there was a Wordpress php command that I could use to go to that post ('View full post'):

<?php

        $new_query = new WP_Query('post_type=team_member&posts_per_page=-1');
            while($new_query->have_posts()) : $new_query->the_post(); ?>

                <div class="team-member">
                    <?php the_post_thumbnail(); ?>
                    <h5><?php the_field('name'); ?></h5>
                    <h6><?php the_field('role'); ?></h6>
                </div>

        <?php endwhile; ?>

This is meant to be a 'card' that links to the full bio page,

I basically want an excerpt of the 'bio' beneath the 'role' and a button that takes you to the page with the whole bio...

Is this possible with a Wordpress command?

Many thanks,

Upvotes: 0

Views: 45

Answers (1)

Dave Olson
Dave Olson

Reputation: 148

Inside your loop you would update the code to something like the following:

<div class="team-member">
  <?php the_post_thumbnail(); ?>
  <h5><?php the_field('name'); ?></h5>
  <h6><?php the_field('role'); ?></h6>
  <a href="<?php the_permalink(); ?>">View Full Post</a>
</div>

You would then need to add a file to your theme called single-team_member.php if you wanted to control that specific custom post type template. If that file does not exist WordPress will fallback to single.php by default.

You can take a look at the single template section template hierarchy for more details.

Upvotes: 1

Related Questions