Join our new community forum for support & discussion

Join Now

Home Support Extensions Opening Hours Change position of opening hours

Change position of opening hours

  • Author
    Posts
  • Bemay1

    How to move the position of the opening hours? I’m looking forward to appear on the secondary page space, just above the description… is there a snippet for that?

    yevhen developer

    Please try this PHP snippet

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
    		if ( isset( $form['fields']['opening_hours'] ) ) {
    			$form['fields']['opening_hours']['_order'] = '195';
    		}
    
    		return $form;
    	},
    	1000
    );
    Bemay1

    Is not working… Can you please check if is the code or Is a problem with my site? (Because I deactivated cache plugin and still did not work…)

    yevhen developer

    If you mean to change opening hours position on edit listing page then please try this PHP snippet

    add_filter(
    	'hivepress/v1/forms/listing_update',
    	function( $form ) {
    		if ( isset( $form['fields']['opening_hours'] ) ) {
    			$form['fields']['opening_hours']['_order'] = '199';
    		}
    
    		return $form;
    	},
    	1000
    );

    If you mean to change opening hours position on listing page (move it from sidebar to above listing description) then please try this PHP snippet

    add_filter(
    	'hivepress/v1/templates/listing_view_page/blocks',
    	function( $blocks, $template ) {
    		$listing = $template->get_context( 'listing' );
    
    		if ( $listing && hivepress()->get_version( 'opening_hours' ) ) {
    			$blocks = hivepress()->helper->merge_trees(
    				[ 'blocks' => $blocks ],
    				[
    					'blocks' => [
    					'page_content' => [
    						'blocks' => [
    							'listing_opening_hours' => [
    								'type'   => 'opening_hours',
    								'model'  => 'listing',
    								'_order' => 59,
    							],
    						],
    					],
    					
    					'page_sidebar' => [
    						'blocks' => [
    							'listing_opening_hours' => [
    								'type'   => 'content',
    							],
    						],
    					],
    				],
    				]
    			)['blocks'];
    		}
    
    		return $blocks;
    	},
    	1000,
    	2
    );
    Bemay1

    Perfect, thank youu!!

Viewing 5 posts - 1 through 5 (of 5 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.