Auto fill in the ID in Divi

  • This topic has 1 reply, 2 voices, and was last updated 11 months ago by Andre Flores.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1164000
    Ace Suares
    Participant

    We use the mphb-divi plugin, it’s not listed in the forum.

    If we use the Divi builder blocks for MPHB, you have to provide an ID. However, the blocks can be used in templates, and in that case, it is needed that the block fills in the ID by itself.

    This is a very quick and dirty fix, but I think it could be done in a better way.

           static function get_availability_calendar($args = array()){
                $defaults = array(
                    'id'           => '',
                    'monthstoshow' => '2,3',
                    'class'        => ''
                );
    
                $args = wp_parse_args($args, $defaults);
    
          // add this line. 
          $args['id'] = get_the_ID();
    
                if($args['id'] !== ''){
                    return do_shortcode('[mphb_availability_calendar class="'.$args['class'].'" id="'.$args['id'].'" monthstoshow="'.$args['monthstoshow'].'"]');
                }
    
                return esc_html__('Please insert accommodation id.');
    
            }
    
    #1164209
    Andre Flores
    Moderator

    Hello Ace,

    Thank you for sharing your insights, it is much appreciated. I will make sure to pass this information to our developers for further consideration.

    Regards,
    Andre

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