Trouble pulling custom post values in loop
-
Hi,
I have a custom post type ‘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']?> <!-- !- Content --> <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 is simply spitting out the titles for every post in the events class. I can’t even see where it would show the title, and am having no luck echoing the description based on that specific title.
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!
- The topic ‘Trouble pulling custom post values in loop’ is closed to new replies.