Join our new community forum for support & discussion

Join Now

Home Support General HivePress Changing number of columns for a specific category

Changing number of columns for a specific category

  • Author
    Posts
  • viniciusbh.soares

    to change the number of columns for the categorie’s view page is just:

    add_filter(
    'hivepress/v1/templates/listing_categories_view_page',
    function( $template ) {
    return hivepress()->helper->merge_trees(
    $template,
    [
    'blocks' => [
    'listing_categories' => [
    'columns' => 2, // Just change columns number by your requirements.
    ],
    ],
    ]
    );
    },
    1000
    );

    but how to change the number of columns for a specific category?

    add_filter(
    'hivepress/v1/templates/[__________?]',
    function( $template ) {
    return hivepress()->helper->merge_trees(
    $template,
    [
    'blocks' => [
    '[__________?]' => [
    'columns' => 2, // Just change columns number by your requirements.
    ],
    ],
    ]
    );
    },
    1000
    );
    yevhen developer

    Could you clarify you want to change number of columns for listings in specific category or you want to change number of columns for subcategories in specific category?

    viniciusbh.soares

    I want to change number of columns for listings in specific category, example only in the services listing page shows all listed services in 4 columns.

    yevhen developer

    Please try this PHP snippet. Please just change 123 with category id where you want to change number of columns

    add_filter(
    	'hivepress/v1/templates/listings_view_page',
    	function( $template ) {
    		if(is_tax('hp_listing_category') && 123 === get_queried_object_id()){
    			$template = hivepress()->helper->merge_trees(
    			$template,
    			[
    				'blocks' => [
    					'listings' => [
    						'columns' => 4,
    					],
    				],
    			]
    		);
    		}
    		return $template;
    	},
    	1000
    );
Viewing 4 posts - 1 through 4 (of 4 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.