Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1064351
    bedingfield
    Participant

    Hi there,

    I would like to have a page that pulls in all posts under the category of ‘race-reports’, ideally, I would also like said page to be in the ‘masonry’ format of the ‘blog’ page.

    How would I do this please?

    http://elyrunners.club/blog/

    Thank you for your time.

    #1064433
    Christopher
    Moderator

    Hi there,

    Please select masonry layout Under Customize -> Blog -> Archives.
    Add archive page to top navigation under Appearance -> Menus.

    Hope it helps.

    #1066202
    bedingfield
    Participant

    Hi there,

    I didn’t mean an archive page. I just want one page that will display a page in the style of the masonry layout to display posts only for ‘race reports’ based on tag or category (one or the other).

    Thank you

    #1066304
    Lely
    Moderator

    Hi There,

    Please copy _index.php file from wp-content\themes\x\framework\views\global to wp-content\themes\x-child\framework\views\global. Open the copied file and replace the entire code with this:

    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_INDEX.PHP
    // -----------------------------------------------------------------------------
    // Includes the index output.
    // =============================================================================
    
    $stack = x_get_stack();
    
    if ( is_home() ) :
      $style     = x_get_option( 'x_blog_style' );
      $cols      = x_get_option( 'x_blog_masonry_columns' );
      $condition = is_home() && $style == 'masonry';
    elseif ( is_archive() ) :
      $style     = x_get_option( 'x_archive_style' );
      $cols      = x_get_option( 'x_archive_masonry_columns' );
      $condition = is_archive() && $style == 'masonry';
    elseif ( is_search() ) :
      $condition = false;
    endif;
    
    if ( is_category('race-reports') ) :
      $style     = x_get_option( 'x_blog_style' );
      $cols      = x_get_option( 'x_blog_masonry_columns' );
      $condition = true;
    endif;
    
    ?>
    
    <?php if ( $condition ) : ?>
    
      <?php x_get_view( 'global', '_script', 'isotope-index' ); ?>
    
      <div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>">
    
        <?php if ( have_posts() ) : ?>
          <?php while ( have_posts() ) : the_post(); ?>
            <?php if ( $stack != 'ethos' ) : ?>
              <?php x_get_view( $stack, 'content', get_post_format() ); ?>
            <?php else : ?>
              <?php x_ethos_entry_cover( 'main-content' ); ?>
            <?php endif; ?>
          <?php endwhile; ?>
        <?php else : ?>
          <?php x_get_view( 'global', '_content-none' ); ?>
        <?php endif; ?>
    
      </div>
    
    <?php else : ?>
    
      <?php if ( have_posts() ) : ?>
        <?php while ( have_posts() ) : the_post(); ?>
          <?php x_get_view( $stack, 'content', get_post_format() ); ?>
        <?php endwhile; ?>
      <?php else : ?>
        <?php x_get_view( 'global', '_content-none' ); ?>
      <?php endif; ?>
    
    <?php endif; ?>
    
    <?php pagenavi(); ?>

    Then check for this part of the code:

    if ( is_category('race-reports') ) :
      $style     = x_get_option( 'x_blog_style' );
      $cols      = x_get_option( 'x_blog_masonry_columns' );
      $condition = true;
    endif;

    Replace race-reports with the correct category slug of your specific category that you want to display with masonry style.

    Hope this helps.

    #1067151
    bedingfield
    Participant

    Thanks for this. Is it possible to have a ‘blog’ page and a ‘race reports’ page in masonry style?

    Thank you

    #1067673
    Lely
    Moderator

    Hi There,

    Above code is just for the specific category. We don’t need custom codes if we want Blog index page to be masonry. It can be set in Appearance > Customize > Blog > Style > Choose Masonry. The previous suggestion by Christian will work for all archive and category pages. But then you don’t want that and you just need the specific category to be masonry. That’s the purpose of the previous code.

    Hope this helps.

    #1067968
    bedingfield
    Participant

    Thank you.

    #1068003
    Friech
    Moderator

    You’re more than welcome, glad we could help.

    Cheers!

    #1069634
    bedingfield
    Participant

    Great. Thank you. Its it possible to get ‘tags’ to display as masonry layout when you click on a tag?

    thank you.

    #1069976
    Rue Nel
    Moderator

    Hello There,

    Thanks for the updates! If you want to have a masonry layout for the tag archives, simply edit the code above and add this:

    if ( is_category('race-reports') ) :
      $style     = x_get_option( 'x_blog_style' );
      $cols      = x_get_option( 'x_blog_masonry_columns' );
      $condition = true;
    endif;
    
    if ( is_tag() ) :
      $style     = x_get_option( 'x_blog_style' );
      $cols      = x_get_option( 'x_blog_masonry_columns' );
      $condition = true;
    endif;

    Please let us know if this works out for you.

    #1070314
    bedingfield
    Participant

    Great. Thank you. Can this work for search results as well?

    #1070695
    Rad
    Moderator

    Hi there,

    Yes, you may add this along with it,

    if ( is_search() ) :
      $style     = x_get_option( 'x_blog_style' );
      $cols      = x_get_option( 'x_blog_masonry_columns' );
      $condition = true;
    endif;

    Thanks!

  • <script> jQuery(function($){ $("#no-reply-1064351 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>