Some users have had luck with the following…
<?php
$postid = get_the_ID();
$content = do_shortcode(get_post_field( 'post_content', $postid ));
$content = apply_filters('the_content', $content);
echo $content;
?>
Thanks for the quick reply! unfortunately, that still has the same results – I’m getting the content with the shortcode included as written. The same expander-maker plugin is working in the pre-loaded posts on that page, btw.
Assuming I used the snippet you provided correctly:
<div class='blog-meta'>
<span class='small-preview'<?php if (! has_post_thumbnail() ) { echo ' class="no-img"'; } ?>>
<?php if ( has_post_thumbnail() ) { the_post_thumbnail(array(300,300));
}?></span>
</div>
<div class='entry-content-wrapper clearfix'>
<header class="entry-content-header">
<h2 class="post-title entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span class="post-meta-infos">
<time class="date-container minor-meta updated"><?php the_time("F d, Y"); ?></time>
<span class="blog-categories minor-meta"> <?php the_category();?></span>
</header>
<div class="entry-content">
<?php $postid = get_the_ID();
$content = do_shortcode(get_post_field( 'post_content', $postid ));
$content = apply_filters('the_content', $content);
echo $content; ?>
</div>
</div>
Can you post to their support and ask them how to display their content in ajax calls?
OK, I’ll try that – I was assuming it was a problem with shortcodes in general. I’ll post back if they reply.
I haven’t been able to figure out why some plugin shortcodes display fine in the_content with ajax calls and some don’t. I usually ask that users reach out directly to those plugins for documentation or help.
So I’ve been doing more research on this – I’m also talking to the maker of the other plugin, but I’m trying to get this done so I’m following all the avenues at the same time. Ran across this stack exchange, with a similar issue.
Did some of the troubleshooting there, just to see what would happen, and found the same as the OP there – within the repeater template, “do_shortcode” apparently does not exist BUT I cause an error if I redeclare add shortcode.
Consensus on stack exchange seems to be that there’s no way to force “do shortcode” to *actually* work, the ones that look like they are may just using the same syntax as actual shortcodes but function differently, which is why the apply_filters() was working.
Just FYI…
Hi Jennifer.
Nice find, do you feel like do_shortcode() doesn’t exist in the ajax calls from Ajax load More or this is a broader issue?
I *think* it’s a general ajax issue. At the moment I’m working on just putting in a straight javascript solution to what I was trying to do with expander_maker.
OK. So I have the buttons integrated on the website differently at this point – they’re a straight up .js script of their own.
Unfortunately, they *still* don’t work. I am pretty sure I’m not implementing the alm callback function correctly – I’m completely new at writing javascript, to be honest.
Here’s the script I’m using right now:
jQuery(function() {
var $ = jQuery.noConflict();
var read_more = 'Read More';
var read_less = 'Read Less';
var moreButton = $('.read-more');
moreButton.click(function() {
var $this = $(this);
$this.text($this.text() === read_more ? read_less : read_more);
$this.next('div.more').slideToggle('fast');
});
$.fn.almComplete = function(alm){
moreButton.click(function() {
var $this = $(this);
$this.text($this.text() === read_more ? read_less : read_more);
$this.next('div.more').slideToggle('fast');
});
}
})( jQuery );
Suggestions?
Fixed it – just in case anyone else is having a similar problem / wants a similar feature, here’s the working code:
jQuery(function() {
var $ = jQuery.noConflict();
var read_more = 'Read More';
var read_less = 'Read Less';
var moreButton = $('.read-more');
moreButton.click(function() {
var $this = $(this);
$this.text($this.text() === read_more ? read_less : read_more);
$this.next('div.more').slideToggle('fast');
});
$.fn.almComplete = function(alm){
var $ = jQuery.noConflict();
var read_more = 'Read More';
var read_less = 'Read Less';
var moreButton = $('.read-more');
moreButton.click(function() {
var $this = $(this);
$this.text($this.text() === read_more ? read_less : read_more);
$this.next('div.more').slideToggle('fast');
}); }
})( jQuery );
(Had to redefine variables inside the almComplete function…)
Marking as resolved since my problem is fixed, although the actual integration of the plugin didn’t happen.