Jump to content
Sign in to follow this  
sahib_13

Using opening and closing shortcode in page template

Recommended Posts

I am making website on wordpress and want to use opening and closing shortcode in my website's page template. In that shortcode i want to insert one more shortcode, but i don't know how to do that. Can anyone please help me how to do that ? Below written is the content which i want to insert in my page template with php code.

 

[restrict userlevel="subscriber"][masterslider id="1"][/restrict]

 

After spending a long time on research i found that

 

.$content.

 

should be used between

 

[restrict] [/restrict]

 

to do this . But now i don't know that how to use

 

.$content.

 

as

 

[masterslider id="1"]

 

Please let me know the full coding of this. I would be really thankful to you.

 

Share this post


Link to post
Share on other sites

This is bbcode used within an editor

[restrict userlevel="subscriber"][masterslider id="1"][/restrict]

 

To paste directly into a theme you use normal php code and echo the function/plugin parameters.

 

Or you use wordpress built in do_shortcode() function.

https://developer.wordpress.org/reference/functions/do_shortcode/

<?php
 if ( is_user_logged_in() ){
echo do_shortcode( '[restrict userlevel="subscriber"][masterslider id="1"][/restrict]' );
}
?>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.