Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaBoxes, Custom Fields in Pages / Page Templates? #52

Closed
patrickf0 opened this issue Jan 12, 2014 · 4 comments
Closed

MetaBoxes, Custom Fields in Pages / Page Templates? #52

patrickf0 opened this issue Jan 12, 2014 · 4 comments

Comments

@patrickf0
Copy link

Is it possible to add Meta Boxes to specific Pages by Slug / ID or Page Templates?

@michaeluno
Copy link
Owner

Currently it's not possible. I'll see if I can implement the functionality.

@michaeluno
Copy link
Owner

Now the branch includes this feature: https://github.com/michaeluno/admin-page-framework/tree/v3/meta_box_for_pages

To create a meta box in a page added by the framework, define a class extending the AdminPageFramework_MetaBox_Page class and define the setUp() method and add fields with the addSettingFields() method in there.

And when instantiating the class, the parameters are:

  1. meta box id
  2. meta box title
  3. page slugs - array|string e.g. array( 'my_page', 'my_another_page' ) or 'my_page'
  4. context - normal, advanced, or side
  5. priority - high, core, default, low
new APF_MetaBox_For_Pages_Normal(
    'apf_metabox_for_pages_normal',     // meta box id
    __( 'Sample Meta Box For Admin Pages Inserted in Normal Area' ),    // title
    'apf_first_page',   // page slugs
    'normal',   // context
    'default'   // priority
);

The example classes are located in

  • \admin-page-framework\example\APF_MetaBox_For_Pages_Normal.php
  • \admin-page-framework\example\APF_MetaBox_For_Pages_Side.php
  • \admin-page-framework\example\APF_MetaBox_For_Pages_Advanced.php

The example of instantiating the classes are written in admin-page-framework-demo.php.

meta_box_for_pages

@michaeluno
Copy link
Owner

I'm going to drop the do_{meta box id} and the content_{meta box id} hooks to change them to do_{extended class name} and content_{extended class name} to make it consistent with taxonomy fields and the validation hook, validation_{extended class name} Just in case somebody has started using the branch.

@michaeluno
Copy link
Owner

It's been functioning okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants