I have created a custom post type of Case Studies, and created a list page which gives an overview of each. Some have a link straight to the case study in PDF form and some have a link to a single case study view, where full text and a full size image can be seen.
The problem is with the link to the single view. When you hover over the link it shows a URL which is correct for the name of the case study, and when you click on it, the correct URL is brought up, but the content on the page is the content of a different case study.
Hope someone can help, it's driving me mad now!
This is the list page code:
<article id="content" class="projectListView">
<?php if(have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title('<h1>' , '</h1>'); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php $loop = new WP_Query( array( 'post_type' => 'case-study', 'category_name' => 'construction-case', 'posts_per_page' => -1 ) ); ?>
<?php while ( $loop->have_posts('post_type=case-study') ) : $loop->the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php if (has_post_thumbnail() ) { ?>
<div class="projectThumb left">
<?php the_post_thumbnail(); ?>
</div>
<div class="projectSummary left">
<?php the_excerpt(); ?>
<?php } else { ?>
<div class="caseStudyIcon left">
<a href="<?php the_field('upload_case_study'); ?>"> </a>
</div>
<div class="caseStudySummary left">
<?php the_excerpt(); ?>
<?php } ?>
<?php if (get_field('upload_case_study')) { ?>
<p class="right"><a href="<?php the_field('upload_case_study'); ?>">Download <?php the_title(); ?></a></p>
<?php } else { ?>
<p class="right"><a href="<?php echo get_post_permalink(); ?>">Read more ></a></p>
<?php } ?>
</div>
<?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'blankslate' ) . '&after=</div>') ?>
<?php edit_post_link( __( 'Edit', 'blankslate' ), '<div class="edit-link">', '</div>' ) ?>
</div>
</div>
<?php comments_template( '', true ); ?>
<?php endwhile; ?>
</article>
And this is the single case study page code:
<article id="content">
<?php query_posts( 'post_type=case-study' ); ?>
<?php the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<div class="projectDesc">
<?php the_content(); ?>
</div>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
<?php edit_post_link( __( 'Edit', 'blankslate' ), '<div class="edit-link">', '</div>' ) ?>
</div>
</div>
<?php comments_template( '', true ); ?>
</article>
The actual development site can be viewed here:
http://wp.perfect-image.co.uk/construction/construction-case-studies/