Free and Premium WordPress Plugins & Themes Forums WordPress Plugins Hotel Booking Show max guests for an accommodation type
- This topic has 5 replies, 2 voices, and was last updated 3 years, 7 months ago by Andre Flores.
- AuthorPosts
- April 27, 2021 at 11:26 am #1112892Jeffrey DonchezParticipant
is there a shortcode, or an elementor block that allows me to JUST show the max # guests for an accommodation type? also, is there 1 to JUST show the price (not the prices start at xxx for xxx nights).. just “$169” so I can add my own custom text around it without having to edit the plugin blocks/templates
April 27, 2021 at 11:25 pm #1113001Andre FloresModeratorHello Jeffrey,
Unfortunately, there is no such shortcode/widget available in the Hotel Booking, you may simply add this information in the accommodation type description.
As for the “Prices start at:” text, you may hide it by adding the following code under Appearance ->Customize ->Additional CSS:.mphb-regular-price strong { display: none; }
Or you may use Loco Translate/WPML plugin to change that text to any desired one.
Regards,
AndreApril 28, 2021 at 2:35 pm #1113551Jeffrey DonchezParticipantactually, I just wrote my own function in my theme’s functions.php file to allow me to get the meta-key I wanted via elementor.
April 29, 2021 at 2:00 am #1113675Andre FloresModeratorHello Jeffrey,
I am glad that you were able to custom-code the feature you were looking for.
You might want to share it with our users, perhaps some of them also require this feature.Regards,
AndreApril 29, 2021 at 3:23 am #1113745Jeffrey DonchezParticipantin functions.php of your theme.. add:
function grab_post_meta_shortcode_fn( $atts ) {
$atts = extract( shortcode_atts( array(
‘post_id’ => false,
‘key’ => ”
), $atts ) );
if ( ! $key ) {
return;
}
$post_id = (int)($post_id === false ? get_the_ID() : $post_id);
$data = get_post_meta( $post_id, $key, true );if ( $data ) {
return ‘<span class=”grab-post-meta-value ‘ . sanitize_html_class(‘id-‘ . $post_id) . ‘ ‘ . sanitize_html_class(‘key-‘ . $key) . ‘”>’. $data .'</span>’;
}
}
add_shortcode( ‘grab_post_meta’, ‘grab_post_meta_shortcode_fn’ );then you can call any post meta field you want using the below shortcode on a post:
[grab_post_meta key=”yyy”]
or, if you want to use it on a page, change it to:
[grab_post_meta id=”xxx” key=”yyy”]
where xxx = the id# of the post you are referencing and yyy = the metakey you are trying to call.
note: this requires you to understand how the database works so that you know the actual name of the key you are trying to grab. i.e. in the hotel booking plugin.. “Max Guests” is “mphb_total_capacity”
April 29, 2021 at 11:40 pm #1114177Andre FloresModeratorHello Jeffrey,
Thank you very much for sharing this solution, I hope it will help other users, who also look for the following feature.
Regards,
Andre - AuthorPosts
- You must be logged in to reply to this topic.