Shortcodes within loop stopped working after update

Hello

Here is my layout page: https://www.joffreyballetschool.com/summer-intensives

It is a loop of each term of a custom taxonomy (dance_style) and then a nested loop of the posts in each dance style.

The dropdown on top uses jquery to show/hide items depending on the css class of each item.

I created shortcodes to add the css classes each item. For example, this is what the class field looks like for each column/item
sub-item [terms_ds] [terms_loc] [datem] [theid] {{dc:post:id}}
Screenshot: https://noaviv.d.pr/x1WEwD

The last two I added to help me troubleshoot.

Your dc:post:id works and the correct post ID is added as a class. However, my shortcodes stopped working after I updated the them today. It just adds the ID and classes for the first post listed to each one, instead of the current post in the loop.

Here is a sample of my shortcode codes, they all work the same way. Can you let me know of any adjustments I need to make to this or how I can get that current post ID in the loop to pull the correct data?

function terms_loc() {
    global $post;
    $out = '';
    $terms = get_the_terms( $post->ID, 'intensive_location' ); 
     foreach($terms as $term) {
       $out .= $term->slug . ' ';
     }
    return $out;
    
}

add_shortcode('terms_loc', 'terms_loc');

Reply to add:
I have some shortcodes I am using in text elements that ARE working that are set up the same way as the CSS class shortcodes. For example the Artistic Director text is also a shortcode that is working.

So it seems to be something with the shortcodes in the custom class box.

I reverted to the previous version since I needed this page to work and now my shortcodes work again

Hi @Noaviv,

Although it is a custom coding issue, still curious to know the reason behind that. Please note that we do not guarantee a fix nor compatibility for conflicting code. Before we start investigating it, I would suggest you troubleshoot the following common issue to help us to recognize the reason.

1.Plugin Conflict
2.Theme Update related issue
3.Child Theme Related issue
4.CSS/JS Customization

If you discover that an issue is coming from a custom code or 3rd party plugin, kindly consult with a developer or contact the plugin author. Please note that we do not provide support for custom codes and 3rd party plugins.
If none of the above helps, please copy your live site to a staging server and update the theme, so we could troubleshoot the issue freely without breaking your live site.
And give us access in the secure note including:

– WordPress Site URL & Login URL
– WordPress Admin username/password

To create a secure note, click the key icon underneath any of your posts.

Thanks

Thank you, I will work on getting my staging environment synced and send over the info.

Hi @Noaviv,

Please let us know once the staging is ready to access.

Thanks

This is happening to me on several sites as well. Here is an example of a shortcode I created in function.php of the child theme which gave me trouble after the update:

function get_home_recent_posts() {
	$args = array( 
		'post_type'			=> 'post', 
		'posts_per_page'	=> '3',
		'orderby'			=> 'DESC',
		'offset' 			=> '1',
		);
	// The Query
	$the_query = new WP_Query( $args );

	// The Loop
	if ( $the_query->have_posts() ) {
		echo '<div class="recent-post-box boxfix">';
		
		echo '<div class="clearfloat"></div>';
	 	while ( $the_query->have_posts() ) {
	    	$the_query->the_post();
  			if ( has_post_thumbnail() ) :
  				echo '<div class="recent-posts">';
  					echo '<a href="' . get_the_permalink() . '">';
  						the_post_thumbnail( 'medium', array( 'class' => 'home-featured-img' ) );
  						echo '<h2>'. get_the_title() . '</h2>';
  					echo '</a>';
  				echo '</div><!-- /recent-posts -->';
  			endif;
		}
		echo '<br class="clearfloat" />';
		echo '</div><!-- /recent-post-box -->';
		
	}

	/* Restore original Post Data */
	wp_reset_postdata();
}
add_shortcode( 'home-recent-posts', 'get_home_recent_posts' );

As you can see, this is nothing fancy, just a simple little loop to grab some recent posts. The shortcode was implemented within the builder using the old Content Area element from a few versions back - before V2 elements even existed. After updating to 4.3.2 from 4.2.3 this broke everything. The posts were outputting above the header and the display was massively jacked up in general. This happened on several sites and was really not fun to deal with…

How I fixed it (some of the time):
Simply implemented the shortcode in a V2 text element instead and deleted the old Content Area. I even tried to use the newer Raw Content element with limited success. But the Text element seemed to work in the majority of cases.

The still very weird and concerning thing:
One of these sites does not use any custom shortcodes. But it does make use of the plugin The Grid. The grid element inserted in the builder is a shortcode of course but it is not custom. It is how this has always worked. Just paste it into a Content Area element and The Grid you build in the plugin is displayed (well, in the front end, the builder always has trouble - that is not what I am talking about here).

On this site however, changing to a text element made no difference at all. The site was just as messed up after doing that. Again, not awesome.

Conclusions:
Something has changed fundamentally about the way these shortcodes are being executed from inside elements since the last release. The code we are implementing was put in place by a developer we already hired - that’s how it got there to begin with (in my case, it was me personally but other’s may have outsourced help and paid for that already to be working). It is not acceptable to suggest that we need to hire a developer to fix what got broken from software you pushed out when it has worked literally the entire time before. In other words, the problem is not with the shortcodes (or functions they call when executed) but rather with the way Pro is handling them after an update. It is incumbent on you guys to address that in some way because, as I’ve said, this is not isolated to custom programming. The Grid is out of whack in some cases too, as in my example.

What can you tell us about your plans to address this issue? It is pretty urgent as you can imagine.
Thanks in advance.

Hello @simeoned,

Thanks for updating the thread. We kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

Regards.

I am happy to post my question in another thread but the question(s) I asked are absolutely relevant to this topic.

Thank you @simeoned.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.