Support » Developing with WordPress » How to show a shortcode “inline” with the text

  • Resolved mrprainx



    I’ve created a simple shortcode which retrieves the first name of the current logged in user. Here’s the code:

    // Add Shortcode For Donor Name
    function nome_donatore_shortcode() {
    	$current_user = wp_get_current_user();
         * @example Safe usage: $current_user = wp_get_current_user();
         * if ( !($current_user instanceof WP_User) )
         *     return;
        echo $current_user->user_firstname;
    add_shortcode('nome-donatore', 'nome_donatore_shortcode');

    I’m using Visual Composer. So I’ve mapped it and placed it where I need the name to show. Everything works fine, but I can’t understand why the name appears before any content in the page, no matter where I placed it.

    Screenshot here.

    I’m not totally familiar yet with PHP language. I’m working on it. 😀 Maybe I have to add something in the shortcode?

    Thank you in advance.

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