Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #171228

    Hi

    I am trying to create a shortcode which would hide content between the shortcodes.

    For example:
    function mcp_premium_content( $atts, $content = null ) {
    if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ){
    return $content;
    } else {
    return ”;
    }
    }

    And now the following can be put into any post, page, or widgetized area to filter who sees your content.

    [premium]**Any Content Here Can Only Be Viewed
    By Registering and Logging In Users**[/premium]

    But this still seems to return all page content.
    I am creating the page using
    [av_textblock ]
    [premium]
    [/av_textblock]

    [av_one_full first]
    [av_textblock]
    Lorum ipsim
    [/av_one_full first]
    [/av_textblock]

    [av_textblock ]
    [/premium]
    [/av_textblock]

    Is this because of nested shortcodes clashing do you think?
    Is there an easy way round this?

    thanks

    #171508

    Hello philipewen!

    Yes, you can’t nest the shortcodes this way. You need to close all shortcodes within the same textblock. If you want to hide the content of several textblocks you need to nest them like

    
    [av_textblock ]
    [premium]
    Your Content....
    [/premium]
    [/av_textblock]
    
    [av_textblock ]
    [premium]
    Your Content....
    [/premium]
    [/av_textblock]
    
    [av_textblock ]
    [premium]
    Your Content....
    [/premium]
    [/av_textblock]
    

    Cheers!
    Peter

    #171512

    Thanks for the response Peter.

    How would i therefore do this for other ‘objects’ say the icon list object? – there is no ability to add pre and post text on these, so the only option is to put a text block above and a text block below.

    Any ideas?

    #171519

    Hi!

    Yes, it’s indeed not easily possible to use the shortcode with these elements. The only workaround I can imagine is to use the “Magic wand” shortcode generator (standard text editor) to generate the icon list shortcode and then you can copy/paste the shortcode into the text editor field of the textblock.

    Best regards,
    Peter

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Hide content shorcode’ is closed to new replies.