I currently have a page on a site that I am developing and that contains a loop which loops through 4 posts contained in a custom post type called Treatments. http://wptest.lancscps.co.uk/treatment-approaches/ As you can see there is a post_excerpt and I would like the user to be able to click through to a single custom post which contains the entire information.
<?php
// Custom loop that adds a clearing class to the first item in each row
$args = array('numberposts' => -1, 'order' => 'ASC', 'post_type' => 'treatments' ); //For this example I am setting the arguments to return all posts in reverse chronological order. Odds are this will be a different query for your project
$allposts = get_posts($args);
$numCol = 2; // Set number of columns
// Start Counter
$counter = 0;
foreach ($allposts as $post) {
$content = '<div class="six columns margin-main-content'.' '.($counter % $numCol == 0 ? 'alpha' : 'omega').'">'; // Add class to the columns depending on if it is odd or even
$content .= '<section class="treatments lightgrey-background">';
$content .= '<figure>'.get_the_post_thumbnail( $post->ID, 'post-two-column' ).'</figure>';
//we need to provide a fallback image in the form of an if else statement?
$content .= '<h4>'.$post->post_title.'</h4>';
$content .= '<p>'.$post->post_excerpt.'</p>';
$content .= '<a href="'.get_permalink( $post->ID ).'"class="button">Find Out More</a>';
$content .= '</section>';
$content .= '</div>';
echo $content;
$counter ++;
}
?>
Is it straightforward to pass the post id when the user clicks on the read more button using something like a hidden form field through to a single page template. This is so that the entire contents of that post could be spit out using a loop that can output the content based on the id that was passed in. I don't know how to code something like that?