Add Templates using Page Builders
You can build a custom Template visually moving the content elements like title, featured image, content(description), gallery, attribute details, availability form, calendar, price, etc., and apply it to all your Accommodation Types:
Block Editor (Gutenberg) - Create a custom layout of the Accommodation Page using the Block Editor
Elementor - Create a custom layout of the Accommodation Page using Elementor
Overriding plugin files, actions, and filters (for Developers)
There are 2 Template Modes available in the settings of the Hotel Booking plugin - Theme and Developer
Theme Mode - by default, this mode is selected, and in this case, the layout of the accommodation type is inherited from the single.php file of your active theme. You may override it by duplicating the single.php file and renaming the duplicated file to single-mphb_room_type.php in the root folder of your theme. You can edit the file by adjusting the template, removing the sidebar, post meta information like date, author, etc.
Here is a list of actions to override system-generated meta blocks like Gallery, Details (Attributes), Price, Availability Calendar, and Availability Form. You can use them to modify/replace/remove blocks on single Accommodation Type pages:
//Featured gallery
add_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderGallery' ), 10 );
//Attributes (Details):
add_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderAttributes' ), 20 );
//Default Price:
add_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderDefaultOrForDatesPrice' ), 30 );
//Availability Calendar:
add_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderCalendar' ), 40 );
//Reservation Form:
add_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderReservationForm' ), 50 );
An example of how to relocate the Featured Gallery under the Attributes on single Accommodation Type pages. You need first to remove the action of the gallery by adding the code to your child theme functions.php file or using a third-party plugin like Code Snippets:
remove_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderGallery' ), 10 );
Add it again with a different priority value:
add_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderGallery' ), 20 );
An example of how to remove the Availability Calendar from single Accommodation Type pages:
remove_action( 'mphb_render_single_room_type_metas', array( '\MPHB\Views\SingleRoomTypeView', 'renderCalendar' ), 40 );
Developer Mode - If you select this mode in the plugin settings, then the layout of the accommodation type is inherited from the following file
\wp-content\plugins\motopress-hotel-booking\templates\single-room-type.php
You can copy the file to your theme folder to add custom wrappers, classes, etc. The path is as follows:
\wp-content\themes\theme-folder\hotel-booking\single-room-type.php
Note: The actions described above do not work when the Developer mode is selected.
The display of other elements of the Accommodation Type can be changed by overriding plugin files from \motopress-hotel-booking\templates\single-room-type\ folder. For example, you can copy the file of the title
\wp-content\plugins\motopress-hotel-booking\templates\single-room-type\title.php
and paste it at
\wp-content\themes\theme-folder\hotel-booking\single-room-type\title.php
Note: You will need to create the \hotel-booking\single-room-type\ directory manually in the folder of your active theme.
Comments
0 comments
Article is closed for comments.