Shortcode Issue (3 posts)

  1. TecHalo
    Posted 2 years ago #


    I'm pretty new here, so I would like to start by apologizing if this is a ridiculous question.

    I've attempted to setup shortcodes to show content to users if they are logged in, or logged out. Then I'm trying to use that shortcode to wrap around an additional short code. I've listed my example below. Is this doable, or am I chasing something that cannot be done? I appreciate any feedback.

    [loggedout][button size="small" icon="home" color="alternative-1"]Login[/button][/loggedout]
    [loggedin][button size="small" icon="home" color="alternative-1"]Logout[/button][/loggedin]


  2. kvvaradha
    Posted 2 years ago #

    i think you are getting into the deep .

    better use the following code.

    open your theme and open the single.php file and

    add the following if statement to allow registered users to see your posts,

    if(is_user_logged_in() ) {
    // your single content goes here. 
    } else {
    // prevented access. login to see the content. 

    I think it will be your necessary one.

  3. Michael
    Forum Moderator
    Posted 2 years ago #

    I'm trying to use that shortcode to wrap around an additional short code.

    what is the exact full code of your shortcode function?

    do you use do_shortcode( $content ) like shown in:

    If the enclosing shortcode is intended to permit other shortcodes in its output, the handler function can call do_shortcode() recursively:

    function caption_shortcode( $atts, $content = null ) {
       return '<span class="caption">' . do_shortcode($content) . '</span>';


Topic Closed

This topic has been closed to new replies.

About this Topic