Support » Developing with WordPress » Adding part of a php page between an open and close shortcode tags

  • mrjorgefilho


    I need to define as restricted only part of the site – to logged in users – and I will use the shortcode [private] … [/private] with a php code inside.

    I want to restrict only the line of ‘attachments’ so that it looks something like the code below:

    <? php get_template_part(‘template-parts/single-property/video’); ?>
    <? php get_template_part(‘template-parts/single-property/attachments’); ?>

    I’m sorry if this sounds repetitive to you, but I really did research a lot and none of the similar topics in this and other forums solved my question.

    Hopeless level! 🙂 Thanks for your help!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Kartik Shukla


    Hello mrjorgefilho,

    I think you need a way to insert the PHP code in your WordPress Editor.

    It can be possible to do that via Plugin. I did some quick analysis and found some useful links which might help you.

    Hope this information helps.




    Hello, Kartik, thank you for your attention!
    The goal is not to add PHP to the page, but to edit an existing template using the WordPress editor.
    I opened a php file from my template and I need to add that shortcode inside this php code.

    Moderator bcworkz


    You are using the theme editor to edit a PHP file, right? Shortcodes don’t work there. Shortcodes only work in post content. And you cannot normally put PHP in post content. All shortcodes really do is execute predefined PHP as the content is output. So if you are editing a template’s PHP, just place the necessary PHP to do what you want.

    You can use is_user_logged_in() to conditionally do something only for logged in users.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.