Show max guests for an accommodation type

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1112892
    Jeffrey Donchez
    Participant

    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

    #1113001
    Andre Flores
    Moderator

    Hello 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,
    Andre

    #1113551
    Jeffrey Donchez
    Participant

    actually, 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.

    #1113675
    Andre Flores
    Moderator

    Hello 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,
    Andre

    #1113745
    Jeffrey Donchez
    Participant

    in 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”

    #1114177
    Andre Flores
    Moderator

    Hello 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

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