WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type sorted by Category and displays only the thumbnail (1 post)

  1. J. Gay
    Member
    Posted 1 year ago #

    I've created a page template that will display staff members by custom post type: staff then by category. The page will display the post as a thumbnail and when clicked, the thumbnail loads the staff member's information (the post content) in an iframe below. I've gotten this to work but with two problems:

    One - Only one post thumbnail will display.

    Two - The subpages will only display the same thumbnail as the parent page no matter what category I specify.

    I thought it was going well but I'm lost at this point.

    Page Template:

    <?php $query = new WP_query( 'post_type=staff&cat=12&posts_per_page=-1' ); ?>
    
    <!-- START "THE LOOP" -->
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
    
    <?php the_content(); ?>
    
    <section class="post-content">
    <?php $thumbnails = get_posts();
    	foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
          echo '<a href="' . post_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '" target="meet-the-team-post-wrapper" class="staff-thumb">';
          echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');
          echo '</a>';
        }
      }
    ?>
    
    </section> <!-- end article section -->
    
    <iframe id="meet-the-team-post-wrapper" class="clearfix box-style autoHeight" name="meet-the-team-post-wrapper" scrolling="no">
    </iframe>
    
    </article> <!-- end article -->
    
    <?php endwhile; ?>
    <?php else : ?>

    The sub-page templates are exactly the same with only the category id changed.

Topic Closed

This topic has been closed to new replies.

About this Topic