• Resolved Jennifer Soucy

    (@guenievre)


    I’m trying to make a custom repeater template that calls the full content of each post, as each post in my current configuration will be using the expander_maker plugin to expand in place, rather than being loaded on a separate page. I’ve gotten the template to show the pieces I want, with the classes applied that I want. Unfortunately, I can’t seem to force the plugin to run the shortcode within the content as it loads – I’ve tried various iterations of do_shortcode and apply_filters but I think I’m just not getting the code right.

    Here’s my template as it stands right now:

    <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”>” title=”<?php the_title(); ?>”><?php the_title(); ?></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 $display = apply_filters(‘the_content’,get_the_content());
    echo do_shortcode ($display); ?>
    </div>
    </div>

    Site in progress is here: https://www.hlinc.com/news/

    https://www.ads-software.com/plugins/ajax-load-more/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    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;
    ?>
    Thread Starter Jennifer Soucy

    (@guenievre)

    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>

    Plugin Author Darren Cooney

    (@dcooney)

    Can you post to their support and ask them how to display their content in ajax calls?

    Thread Starter Jennifer Soucy

    (@guenievre)

    OK, I’ll try that – I was assuming it was a problem with shortcodes in general. I’ll post back if they reply.

    Plugin Author Darren Cooney

    (@dcooney)

    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.

    Thread Starter Jennifer Soucy

    (@guenievre)

    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…

    Plugin Author Darren Cooney

    (@dcooney)

    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?

    Thread Starter Jennifer Soucy

    (@guenievre)

    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.

    Thread Starter Jennifer Soucy

    (@guenievre)

    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?

    Thread Starter Jennifer Soucy

    (@guenievre)

    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.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Integrating Expander_Maker in content’ is closed to new replies.