Why doesn't the shortcode appear inside the elementor html widget?

Issue

I have some custom html, css and js inside elementor’s html widget. At some point I had to insert a div tag with a shortcode made by me inside. The shortcode displays fine in elementor’s shortcode widget, but does not display inside elementor’s html widget. Why does this happen ?

This is the shortcode I have in functions.php – It works everywhere except in elementor’s html widget

// Shortcode current username
function display_current_username () {
    $user = wp_get_current_user();
    $name = $user->user_firstname;
    
    // If the $name var is empty, return the user_firstname property.
    if ( $name === '' ) :
        return $user->display_name;
    endif;
    
    return $name;
}
add_shortcode('display_name', 'display_current_username');

Solution

You can use the shortcode widget of Elementor and use the html elements before or after the shortcode. It will work perfectly. But inside the HTML widget it will not work as the widget is not for running shortcode.

Use it like this inside the shortcode widget –

<div><b>[display_name]</b></div>

Answered By – Benjir Ahmed

Answer Checked By – Cary Denson (AngularFixing Admin)

Leave a Reply

Your email address will not be published.