I have a custom WordPress post type called 'events', which includes date and description fields. I've listed them successfully on a page with their permalinks, which results in a link ending in:
/events/ingenuity-2014-kick-off-reception/?title=Ingenuity%202014%20Kick-Off%20Reception
So I'm passing the title in the URL, and then have this code in single.php:
<?php $title = $_GET['title']?>
<div id="content" class="content" role="main">
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'events',
'order' => 'asc'
);
$eventslist = new WP_Query( $args );
while ($eventslist->have_posts()) : $eventslist->the_post();
$actual_title = the_title();
if($title==$actual_title) {
$description = get_field('description');
$date = get_field('date');
?>
The description:
<?php echo $description ?>
<?php echo $date ?>
</div>
<?php } ?>
For some reason, the resultant single.php page containing the above code is simply spitting out the titles for every post in the events class. I'm having no luck echoing the description based on only the specific title for the post in question.
Is it the %20 that is messing me up? I thought GET would deal with those. Is it something else I'm missing? I'm really stumped... thanks for any help!