• Hi !

    Ajax Load More is really a great plugin and I would like to use it for my posts displayed in Masonry.

    But I have two problems with my posts and I think they are caused by the code that I use in the “Repeater Templates”.

    My first problem is that my button “Load More” works but the posts are displayed in a list and not in Masonry.
    And my second problem is that after clicking for the first time on Load More button, the posts restart from the beginning (so the ten first posts appear a second time).

    I use a archive-masonry.php for the posts :

     
    <?php if (have_posts()) {
    echo '<div class="post-archive">';
      while (have_posts()) : the_post();
        $current = $wp_query->current_post + 1;
    
        if ($current == 1) {
    
          if ($show_first == true) {
            echo '<div class="post-archive-standard">';
            is_featured() ? get_template_part('templates/content', 'featured') : get_template_part('templates/content', 'standard');
            echo '</div>';
          }
    
          echo '<div class="post-archive-masonry">';
          echo '<div class="row">';
    
          if ($show_first == false) {
            echo '<div class="col-masonry col-lg-' . 12 / $columns . '">';
            is_featured() ? get_template_part('templates/content', 'featured') : get_template_part('templates/content', 'masonry');
            echo '</div>';
          }
        }
    
        else {
          echo '<div class="col-masonry col-lg-' . 12 / $columns . '">';
          is_featured() ? get_template_part('templates/content', 'featured') : get_template_part('templates/content', 'masonry');
          echo '</div>';
        }
    
      endwhile;
      echo '</div>';
      echo '</div>';
    }

    So on my Repeater Templates, I put this short code that I thought it would have called my posts displayed in Masonry :

    <div class="post-archive-masonry">
    <div class="row">
    <div class="col-masonry col-lg-' . 12 / $columns . '">
    <?php is_featured() ? get_template_part('templates/content', 'featured') : get_template_part('templates/content', 'masonry'); ?>
    </div>
    </div>
    </div>

    Thanks a lot for your time,
    I hope to have been clear.

    Ruubis

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

    (@dcooney)

    Hi Ruubis,
    Your repeater template should like only be get_template_part('templates/content', 'masonry')

    The other code appears to be part of the container.

    Does that make sense?

    Thread Starter ruubis

    (@ruubis)

    Hi dcooney,

    Thank you for your reply.

    I tried your suggestion but it doesn’t seem to work, I still have my two problem.

    My “$columns” is the value of how many columns I want for the masonry.
    I also tried with this code to get the number of columns but it doesn’t work.

    <div class="post-archive-masonry">
    <div class="row">
    <?php $columns = _get_field('csco_category_layout_archive_columns', 'category_' . $cat, 'default'); ?>
    <div class="col-masonry col-lg-' . 12 / $columns . '">
    <?php get_template_part('templates/content', 'masonry'); ?>
    </div>
    </div>
    </div>
    

    Here a screenshot of what it looks like when I click on the “Load More” button :
    Problem Masonry

    My posts is in fullwidth, that’s why I think it’s a problem of column but I’m not totally sure.

    If you have any idea, thanks for sharing.

    Ruubis

    • This reply was modified 8 years, 6 months ago by ruubis.
    • This reply was modified 8 years, 6 months ago by ruubis.
    Plugin Author Darren Cooney

    (@dcooney)

    You won’t be able to pass $columns to your repeater template. You will need to hardcode this value or define this as a global php variable.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem of display with Masonry’ is closed to new replies.