• Resolved adelivuk

    (@adelivuk)


    Hello,

    I have some issues with the plugin. The repeater template looks like:

    
    <a class="blog-post" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
      <div class="blog-post-container <?php if (! has_post_thumbnail() ) { echo ' no-img'; } ?>">
        <div class="blog-post-image">
          <?php if ( has_post_thumbnail() ) { 
    
            $imagePath = get_the_post_thumbnail_url(get_the_ID(), 'large');
            $backgroundcolor = get_post_meta(get_the_ID(), 'background-color-header-hex', true);
    
          } ?>
          <div class="blog-post-image-url" style="background-image: url('<?php echo $imagePath; ?>');"></div>
          <div class="blog-post-inner" style="background-color: <?php echo ($backgroundcolor[0]=='#'?'':'#').$backgroundcolor ?>"></div>
        </div>
        <div class="blog-post-content">
          <div class="blog-post-author">
            <span class="author-avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), 48 ); ?></span>
            <span class="author-name">By <?php the_author() ?></span>
          </div>
          <div class="blog-post-title">
            <h2 class="post-title"><?php the_title(); ?></h2>
          </div>
          <div class="blog-post-footer">
            <span><?php echo do_shortcode('[rt_reading_time]'); ?>min read</span>
            <span><?php echo pvc_post_views(); ?></span>
          </div>
        </div>
      </div>
    </a>
    

    Which breaks the layout – https://ibb.co/S7NmTr2

    But when I remove the <span class="author-avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), 48 ); ?></span> part it works just fine – https://ibb.co/jV868Zq

    What can be the issue?

    Also if I just put the <span class="author-avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ), 48 ); ?></span> in the repeater template, it also works. I doubt its due the image.

    Thanks for the help

    The page I need help with: [log in to see the link]

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

    (@dcooney)

    Hi @adelivuk,
    Is there actually a PHP error, or is it just the image issue?

    If it’s just the image issue, it’s likely the default ALM CSS causing this and it positions the image absolute to the left.

    To fix this, you could follow the docs to copy the core ALM CSS to your theme and make the adjustments as needed.
    https://connekthq.com/plugins/ajax-load-more/docs/css-stylesheets/

    Let me know if this helps.

    Thread Starter adelivuk

    (@adelivuk)

    Hy @dcooney,

    I really don’t know what seems to be the issue.

    Without the <img> element it renders good – https://ibb.co/VSPrwRg

    And when I add just the <img src="some-url"> it breaks (the dog image is added in the repeater template) – https://ibb.co/8K3nNRR

    Check the DOM on the right side, like the AJAX LOAD MORE content is not injected in the right spot.

    And the error in the console is also present.

    
    ajax-load-more.min.js?ver=5.1.2:12 Uncaught TypeError: Cannot read property 'style' of undefined
        at new t (ajax-load-more.min.js?ver=5.1.2:12)
    

    The interesting thing is that the same code WORKS on the staging server.

    WP version is 4.9.10. and the ALM plugin is 5.1.2. – both on the production and the staging.

    Do you have some clue what could be the issue?

    Tnx

    Plugin Author Darren Cooney

    (@dcooney)

    Hi @adelivuk,
    This error:
    ajax-load-more.min.js?ver=5.1.2:12 Uncaught TypeError: Cannot read property 'style' of undefined at new t (ajax-load-more.min.js?ver=5.1.2:12)

    Is usually an issue with an unclosed or extra closing div or another element in the template.
    https://connekthq.com/plugins/ajax-load-more/docs/faqs/#22

    I’d start by inspecting why/what/how that could be happening in the Repeater.

    Hope that helps.

    Thread Starter adelivuk

    (@adelivuk)

    @dcooney

    If I just add

    <img src="https://www.petmd.com/sites/default/files/Acute-Dog-Diarrhea-47066074.jpg" alt="lorem" />

    To the repeater template, I get the same error – https://ibb.co/F8bzgCH

    As you can see, there are no unclosed HTML elements.

    Plugin Author Darren Cooney

    (@dcooney)

    Strange,
    Just tried the same functionality (paging + ALM) and Repeater Template on my dev and it’s working as expected.

    Possibly a script caching issue on production?

    Thread Starter adelivuk

    (@adelivuk)

    @dcooney

    > Possibly a script caching issue on production?

    Yea, it could be because of the caching, maybe due the cloudflare. Will let you know.

    Thanks for the help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘The script returns error’ is closed to new replies.