Title: do_shortcode command and wrapping content
Last modified: January 7, 2019

---

# do_shortcode command and wrapping content

 *  Resolved [vkristic](https://wordpress.org/support/users/vkristic/)
 * (@vkristic)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/)
 * Hi! If I try to put your shortcode [passster] in a template file like this:
    `
   <?php echo do_shortcode('[passster password="0123456789"]'); ?>` it won’t wrap
   any of content.
 * My intention is to wrap a content in a template file like this:
 *     ```
       <?php echo do_shortcode('[passster password="0123456789"]'); ?>
       <article>My content ... end of content</article>
       <?php echo do_shortcode('[/passster]'); ?>
       ```
   
 * However, [/passster] is not a shortcode for itself, so I would need a different
   closing shortcode, like [passsterclose] or something similar. Would that be possible
   anyhow?
 * The main problem is that I would change passwords in future and I want that every
   post and page update it’s password when I change it.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdo_shortcode-command-and-wrapping-content%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [patrickposner](https://wordpress.org/support/users/patrickposner/)
 * (@patrickposner)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11083786)
 * Hey [@vkristic](https://wordpress.org/support/users/vkristic/),
 * instead of using another shortcode I have build a function in 3.1.8 which you
   can use in your templates.
 * Here is an example:
 *     ```
       if ( true === passster\PS_Conditional::is_password_valid( '123' ) ) {
            the_content();
        }
       ```
   
 * Pass in your password and the function will handle the rest for you 🙂
 * Best regards,
    Patrick
 *  Thread Starter [vkristic](https://wordpress.org/support/users/vkristic/)
 * (@vkristic)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11086584)
 * It works great! Thank you!
 *  Thread Starter [vkristic](https://wordpress.org/support/users/vkristic/)
 * (@vkristic)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11276849)
 * Hi Patrick, I just upgraded to Passster Pro and this solution for templates isn’t
   working any more with multiple passwords.
 * I tried with this:
 *     ```
       <?php
       		if ( true === passster\PS_Conditional::is_password_valid( '123', '456', '789' ) ) {
           	 the_content();
        		} ?>
       ```
   
 * Only first password (123) works.
    -  This reply was modified 7 years, 3 months ago by [vkristic](https://wordpress.org/support/users/vkristic/).
 *  [patrickposner](https://wordpress.org/support/users/patrickposner/)
 * (@patrickposner)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11276876)
 * Hey [@vkristic](https://wordpress.org/support/users/vkristic/),
 * thanks for your message and your upgrade!
 * Yes, the function from this post is for single passwords only.
    If you want to
   use it with multiple passwords you need „are_passwords_valid“.
 * I have build you a small example here:
 *     ```
       $passwords = array('123', '345', '678' );
   
       if ( true === passster\PS_Conditional::are_passwords_valid( $passwords ) ) {
            the_content();
       }
       ```
   
 * Best regards,
    Patrick
 *  Thread Starter [vkristic](https://wordpress.org/support/users/vkristic/)
 * (@vkristic)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11276917)
 * Something is still wrong.
 * I put this:
 *     ```
       $passwords = array( '123', '456', '789' );
   
       if ( true === passster\PS_Conditional::are_passwords_valid( $passwords ) ) {
            	the_content();
       }
       ```
   
 * And set multiple passwords in plugin settings to 123, 456, 789
 * But it does not work.
 * Web: [https://download.bug.hr](https://download.bug.hr)
    -  This reply was modified 7 years, 3 months ago by [vkristic](https://wordpress.org/support/users/vkristic/).
 *  [patrickposner](https://wordpress.org/support/users/patrickposner/)
 * (@patrickposner)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11276962)
 * Hey [@vkristic](https://wordpress.org/support/users/vkristic/),
 * sorry my fault. There is no need for an array, so use this instead:
 *     ```
       $passwords = '123,345,678';
   
       if ( true === passster\PS_Conditional::are_passwords_valid( $passwords ) ) {
            the_content();
       }
       ```
   
 * That should do the trick.
 *  Thread Starter [vkristic](https://wordpress.org/support/users/vkristic/)
 * (@vkristic)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11277029)
 * Thank you! This is it… Regards!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘do_shortcode command and wrapping content’ is closed to new replies.

 * ![](https://ps.w.org/content-protector/assets/icon-256x256.png?rev=2206760)
 * [Passster - Password Protect Pages and Content](https://wordpress.org/plugins/content-protector/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/content-protector/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/content-protector/)
 * [Active Topics](https://wordpress.org/support/plugin/content-protector/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/content-protector/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/content-protector/reviews/)

## Tags

 * [do_shortcode](https://wordpress.org/support/topic-tag/do_shortcode/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 7 replies
 * 2 participants
 * Last reply from: [vkristic](https://wordpress.org/support/users/vkristic/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/do_shortcode-command-and-wrapping-content/#post-11277029)
 * Status: resolved