• Hey guys, I’m trying to generate a shortcode but with a variable.

    <?php echo do_shortcode( '[sabai-directory-listings return="1" user_name="' . $admin . '"]' ); ?>

    This returns all posts made by admin where username is admin…

    I want to replace that with “where username = the user profile”

    This shortcode is placed within the view profile php file in my theme…

    So you go to https://www.website.com/profile/user1

    And this short code will display

    <?php echo do_shortcode( '[sabai-directory-listings return="1" user_name="' . $user1 . '"]' ); ?>

    I am really stuck with this and could do with some help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter zuko

    (@zuko)

    <?php echo do_shortcode( ‘[sabai-directory-listings return=”1″ user_name=”‘ . $current_user . ‘”]’ ); ?>

    Would this work?

    Thread Starter zuko

    (@zuko)

    The following spits out all listings by admin

    <?php echo do_shortcode( ‘[sabai-directory-listings return=”1″ user_name=”admin”]’ ); ?>

    I want to place this code in the profile.php file in my wordpress theme to show the listings from the user the profile you are viewing at the time dynamically

    Something like;

    <?php echo do_shortcode( ‘[sabai-directory-listings return=”1″ user_name=”‘ . $userprofileID . ‘”]’ ); ?>

    Thread Starter zuko

    (@zuko)

    Just tried this and it kills the page

    <?php global $current_user;

    $current_user = wp_get_current_user();

    echo do_shortcode( ‘[sabai-directory-listings return=”1″ user_name=”‘ . $current_user . ‘”]’ ); ?>

    Hi zuko: Did you ever solve this problem? I’m facing the same issue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to echo the userid in a doshortcode’ is closed to new replies.