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.

Im trying to figure out howto structure general content that should be easy to import in a page template.

Lets say for example i have some contact details and i want to include this content on multiple pages. One way i tried was to create a custom post type and just add posts for

  • Email
  • Phone
  • Address

I would then simply read the ID's of those posts and in my template hardcode the ID's into some get_post() calls, to extract the content.

The problem with this approach is

  1. im hardcoding ID
  2. lets say my Address needs different input fields like "Street" / "City" "Zipcode". Then i would need to create multiple custom post types, because i cant just add it to the same because it would make no sense for a email to have a zipcode field. I hope to get some pointers to how i would structure content like this. I guess i could write a custom plugin, but then i would miss out on all those features post's has like a rich text field and gallery support, and the support for adding more fields etc.
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Using custom post types for this seems like a bad approach. Instead, create a simple option page in the admin using add_options_page, displayed in the menu under "Settings", for example.

Lay out some input fields for each piece of data you want to save. You can use the options API to read and write each field: get_option and update_option. You could also use shortcodes API to pull up options right inside the post editor.

share|improve this answer
add comment

Alternatively you could use the ICIT Spots plugin and shortcodes:

http://interconnectit.com/2364/announcing-spots/

You can create arbitrary posts containing data and then include them in other posts via shortcodes, or using template function calls, or using widgets, etc You can add them from the widget area too and use them as a text widget with a built in editor, and you can add spot templates so that you can have different styles of spots.

Spots can appear multiple times too in different places.

share|improve this answer
add comment

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.