How to show category page grid in two columns

Hello! I had earlier contacted support for a code to make one of my category pages show up as a grid:

I’d like the posts to show only 2 columns instead of 3. Could you help me figure this out please? Not sure if this helps but the custom JS is:

(function($){
$(’.category-writing .x-iso-container-posts .entry-title a, .category-writing .entry-featured a’).attr(‘target’, ‘_blank’);
})(jQuery);

Thank you!

Hey @ramyasriram1,

It’s best that you override the theme options. Add this code in functions.php.

add_filter('x_option_x_archive_masonry_columns', 'archive_masonry_override');

function archive_masonry_override( $columns ) {  
    if ( is_category( 'writing' ) )  {      
       $columns = 2;
   }
  return $columns;
}

writing is the category set in that code so that should readily work for you. You need to change it if you’re going to apply it to a different category. For more categories, you can turn it to an array like this

is_category( array('audio', 'edge-case-2') ).

When followed correctly, that should work. If not, that could easily break your site. Please just note that since we’re using custom code here, you have the responsibility to learn how the code works because fixing custom code issues and further enhancements are not a part of our support service as you can read in our Terms.

To aid you with learning, you can check out the links below:

If you’re not comfortable with coding, please use one of the bundled grid plugins instead. Please see the links below:

Hope that helps and thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.