WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Template
Custom Post Type templates won't show just 1 post? (2 posts)

  1. morgon
    Member
    Posted 1 year ago #

    I've installed the plugin, and enabled it for custom post types, which is showing up fine. However, I can't seem to limit the post template I've made to only show the 1 post in a single post template kind of way.

    What I'm doing is using the custom post types UI plugin (http://wordpress.org/extend/plugins/custom-post-type-ui/) to create the post types for "Case Studies" on my client's site. There is a "case studies" page template which shows a list of the case studies, and I need to show each case study on their own single page.

    Any help?

    http://wordpress.org/extend/plugins/custom-post-template/

  2. morgon
    Member
    Posted 1 year ago #

    Here's the code I'm using to display this:

    <?php query_posts( 'post_type=case-studies','showposts=1'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <h1 class="page-title" itemprop="headline"><?php the_title(); ?></h1>
    
    <div id="content">
    	<dl>
    		<dt>Situation:</dt>
    		<dd><?php the_field('situation'); ?></dd>
    	</dl>
    
    	<dl>
    		<dt>Challenge:</dt>
    		<dd><?php the_field('challenge'); ?></dd>
    	</dl>
    
    	<dl>
    		<dt>Approach:</dt>
    		<dd><?php the_field('approach'); ?></dd>
    	</dl>
    
    	<dl>
    		<dt>Result:</dt>
    		<dd><?php the_field('result'); ?></dd>
    	</dl>
    
    </div> <!-- end #content -->
    <?php endwhile; ?>
    
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic