Third Party Shortcodes pulling from wrong post

Hi there,

I’m having difficulty using third party shortcodes to display content. Specifically, I’m using the ‘Events Manager’ plugin (http://wp-events-plugin.com/documentation/), and I’m trying to show content from a custom post type that the plugin creates on the post itself. Basically, I create an ‘event’ post with the plugin, use Beaver Builder to create the layout for that single ‘event’ post, and include shortcode from the plugin to display the date and location of the event dynamically.

The shortcode is: [event] … [/event] and pulls the content from whatever post it’s on. When I enter the shortcode in an ‘html’ content type with Beaver Builder, I can see that it pulls in the correct information:
Shortcode while in editor

But when I publish the page and view it, the shortcode now pulls in information from the wrong post:
Shortcode once published

It displays the correct post data in the editing view, but data from a different post when published! If I pass the post’s ID to the shortcode directly [event post_id=“621”] … [/event] it will display correctly.

I’ve posted this on the BB forum as opposed to the ‘Events Manager’ forum because I had a similar issue using the ‘Types and Views’ plugin(wp-types.com), where their shortcode was pulling information from the wrong post in the exact same way. Do you have any insight into this? Is BB modifying a post variable or something? I’m stumped.

The page in question is here: http://allpoints.jeffmaciejko.com/workshops/young-agrarian-okanagan-mixer/

Thanks!

Ended up finding the solution, it didn’t have anything to do with Beaver Builder. Marked as resolved.

Hey Jamaico1,

Glad you figured out the issue! Do you mind sharing what it was that caused it though? :slight_smile:

Ben

I don’t know that it will be that helpful to anyone else, but sure :slight_smile:

I’ve developed a custom theme for this project based on the Bones starter theme (http://themble.com/bones/), and it’s my first attempt at doing this. On the sub-navigation row, under the featured header image, I’ve created a drop-down menu that pulls other posts from this post type. You can see it working here: http://allpoints.jeffmaciejko.com/project/pilot-production-food-forest/ where you can mouse-over ‘more projects’ and you see the 5 most recent projects excluding the one you’re on.

It was this functionality that was causing the issue, as when I removed it from my single-event.php page template everything started working as it should. My guess is that I’ve made a mistake in my code and haven’t correctly reset my postdata for the main loop after calling in this menu query. Here’s the code:

<ul class="sub-menu more-menu">
	<?php $listposts = get_posts('numberposts=5&orderby=date&post_type=event&exclude=' . $wp_query->post->ID);
	foreach($listposts as $post) :
	setup_postdata($post); ?>
	
	<li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>>
	  <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
  </li>

  <?php endforeach; ?>
  <li><a href="/projects/" title="View All Projects">View All</a></li>
</ul>
<?php wp_reset_postdata(); ?>

...

<?php the_content(); ?>

TL;DR - It’s my template that messed things up

Hey Jamaico1,

Thanks for the detailed reply! We really appreciate it. :slight_smile: Enjoy BB! :slight_smile:

Ben