0

I want the user to fill in a form (when they create a new blog post). The results of the form should be embedded within the new blog post. So I am trying to think of the best way of coding this. Meta boxes might be the best way?



Edit, the original question changed a little. The old one was:

How can I add a Dashboard Widget into a custom Plugin Options Page?

I have followed the example here http://codex.wordpress.org/Dashboard_Widgets_API to create a custom Dashboard Widget, but cannot see how to add it into my custom plugin options page (which is found under the 'Settings' sidebar in the Control Panel).

2
  • 1
    Dashboard widgets are for the dashboard, anywhere else they're just widgets/metaboxes. Are you wanting to register a widget for the dashboard inside a plugin and provide a checkbox/field to toggle activation of said registered widget?
    – t31os
    Commented Jan 4, 2011 at 16:23
  • Thank you for the information. MathSmath has now given me the information I need in the answer (edited).
    – Techboy
    Commented Jan 5, 2011 at 10:01

2 Answers 2

2

Dashboard widgets only go on the dashboard. You can't put 'em on any other pages, as far as I know.

For a primer on plugin options, see the codex article on creating plugin options pages.

Is there any reason you need to add a widget-style meta box in your settings page? Are you after the drag-and-drop functionality, or the expand-collapse functionality? If so, you might modify your question to ask for those things specifically.

EDIT What you're looking for (based on your comments) are called meta boxes, not widgets (it takes a while to learn all the WordPress-specific terminology). There are some easy-to-use WordPress functions for adding meta boxes to the post creation/editing page--you don't need to create a separate admin page for them.

To actually save the information entered into these boxes, you'll want to hook into the save_post action.

This is all explained (including a copy/paste example you can play with) in the codex article on the add_meta_box function.

4
  • Thank you for the answer. The reason I was looking to do this is explained in my question wordpress.stackexchange.com/questions/6241/… Please let me know if you can think of a better way of doing what I want to achieve :-)
    – Techboy
    Commented Jan 4, 2011 at 11:45
  • 1
    I'm confused by your reference to that other question... are you trying to add fields to the post creation/editing page, or to a plugin options page? They use different techniques.
    – MathSmath
    Commented Jan 4, 2011 at 15:26
  • I want the user to fill in a form (when they create a new blog post). The results of the form should be embedded within the new blog post. So I am trying to think of the best way of coding this
    – Techboy
    Commented Jan 4, 2011 at 16:42
  • 1
    Ah, I see! I've updated my answer. For posterity, you might want to change the question to something like "How to add meta boxes to the post creation screen" to help folks who might be searching through the questions. The answer I gave has little to do with dashboard widgets.
    – MathSmath
    Commented Jan 4, 2011 at 18:24
1

You can find an example for custom meta boxes on posts and pages i this repository: https://github.com/bueltge/different-type The example save 3 areas wioth values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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