Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My client wants to have several pages in which he can edit small, separate parts of a Wordpress page. For example, there is a callout box in the upper left corner. There is also a small piece of text showing contact information in the lower right corner. I'd like to be able to have all of these pieces of text editable in the same place.

My idea is to have a post structured using shortcodes; something like this:

[top-callout]
This is the top callout text.
[/top-callout]

[bottom-contact-info]
341 Address Rd.
City Comma State 23422
[/bottom-contact-info]

[other-text]
...
[/other-text]

and so on. Is there a way to extract the content of the shortcodes into loop variables? That way in a theme php file I could do something like:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    ...
    <?php echo $post->top_callout; ?>
    ...
    <?php echo $post->bottom_contact_info; ?>
    ...
<?php endwhile; ?>

Or, is there a better way to do this?

share|improve this question

1 Answer 1

A much better way to do that would be to use custom fields so you could pull the data in the loop by using get_post_custom or get_post_meta.

And to make it even easier on your client you can create your own meta box either by code or using a plugin like verve meta box with separate textareas ,input fields, or even WYSIWYG editors.

share|improve this answer
    
i use WPAlchemy for creating my metaboxes, but that's definitely the way to go. –  helgatheviking Aug 13 '11 at 13:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.