Support » Theme: OceanWP » Different number of blog entry columns

  • Resolved corvex

    (@corvex)


    I want to display different number of columns on different blog entry pages depending on the category.

    I know that I can use this code in functions.php to change the number of columns

    function owp_custom_grid_class($columns) {
        $columns = '1';
        return $columns;
    }
    add_filter('ocean_blog_entry_columns', 'owp_custom_grid_class');

    So what rule should I add to determine what number of columns to return? I guess it could be a category ID or slug.

    Thanks in advance!

    • This topic was modified 4 months, 3 weeks ago by corvex.
    • This topic was modified 4 months, 3 weeks ago by corvex.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    You can try the below code –

    function owp_custom_grid_class($columns) {
      if (is_category( 'your-category' ) ) {
        $columns = '1';
      }
      return $columns;
    }
    add_filter('ocean_blog_entry_columns', 'owp_custom_grid_class');

    Works perfect. Thanks a lot!
    Sorry for late reply.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.