0

I have a special template for my homepage. There are many different boxes, and in every box I want to have different content. That should be possible to create over the backends page edit function.

In detail: I want the author to go to the Edit Page panel and enter something like this:

[box_1]Content of first box[/box_1]
[box_2]Content of second box[/box_2]
...

You get it. And in the pagetemplate-homepage.php I want to something like

<div class="box box_1"><?php echo do_shortcode( '[box_1]' ) ?></div>
<div class="box box_1"><?php echo do_shortcode( '[box_2]' ) ?></div>

Understand? I just want to split the content of the author input into several sections of my template. The above method doesnt work. How is to achieve that?

Thanks in advance!

3
  • do_shortcode() only works with shortcodes registered via the Shortcode API: codex.wordpress.org/Shortcode_API Jan 13 '15 at 20:39
  • I would consider looking at using a plugin like Advanced Custom Fields to make the development and your UX cleaner advancedcustomfields.com
    – NickFMC
    Jan 13 '15 at 20:40
  • also, when calling do_shortcode, exclude the square brackets. So: <?php echo do_shortcode( 'box_1' ) ?>
    – darrinb
    Jan 14 '15 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.