• Resolved wmewme

    (@wmewme)


    There is some way to make a dynamic shortcode, to be able to change a value based on another shortcode, for example [mphb_room id “”] [acf field “id_room”] that the id is taken dynamically from the second shortcode created with ACF, I already tested 2 plugins from the wordpress repo but it seems they are already obsolete, if anyone knows any other way to achieve this? Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter wmewme

    (@wmewme)

    The reason I want to do this is because I am designing a site with oxygen builder and I want to make the rooms page dynamic, I only want to design one page and not one for each room

    Plugin Support dimned

    (@dimned)

    Hi @wmewme,
    Thanks for your question. Some shortcodes of the Hotel Booking plugin may fetch the ID of the current post automatically e.g. [mphb_availability] and [mphb_availability_calendar]
    You may add other elements of the property as custom shortcodes too, for example:

    1. Price [mphb_property_price]

    code

    function mphb_property_price_shortcode() {
    
    if ( is_singular( 'mphb_room_type' ) ) {
    if ( mphb_tmpl_has_room_type_default_price() ) :
    
    do_action( 'mphb_render_single_room_type_before_price' );
    mphb_tmpl_the_room_type_default_price();
    do_action( 'mphb_render_single_room_type_after_price' );
    
    endif;
    }
    }
    
    add_shortcode('mphb_property_price', 'mphb_property_price_shortcode');

    2. Gallery [mphb_property_gallery]

    code

    function mphb_property_gallery_shortcode() {
    
    if ( is_singular( 'mphb_room_type' ) ) {
    
    if ( mphb_tmpl_has_room_type_gallery() ) :
    do_action( 'mphb_render_loop_room_type_before_gallery' );
    mphb_tmpl_the_room_type_flexslider_gallery();  
    do_action( 'mphb_render_loop_room_type_after_gallery' );
    endif;
    }
    }
    
    add_shortcode('mphb_property_gallery', 'mphb_property_gallery_shortcode');

    3. Details [mphb_property_details]:

    code

    function mphb_property_details_shortcode() {
    
    if ( is_singular( 'mphb_room_type' ) ) {
    do_action( 'mphb_render_single_room_type_before_attributes' );
    do_action( 'mphb_render_single_room_type_attributes' );
    do_action( 'mphb_render_single_room_type_after_attributes' );
    }
    }
    
    add_shortcode('mphb_property_details', 'mphb_property_details_shortcode');

    The script should be added to the functions.php file of the theme. Thus you may use shortcodes in template builder without indicating IDs and soo ID will be fetched automatically on each property page where this template is applied.
    We also have this feature on our to-do list so we hope to prepare more shortcodes to be able to build the property templates in a more easy way.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamic Shortcode’ is closed to new replies.