Jump to content

Using opening and closing shortcode in page template


sahib_13

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.

 

Link to comment
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]' );
}
?>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.