I would like to add a select list in the Page Attribute
box you see on the right side in the administration interface for pages.
Does anyone know if that is possible?
Or at least add a custom box below this box?
I would like to add a select list in the Page Attribute
box you see on the right side in the administration interface for pages.
Does anyone know if that is possible?
Or at least add a custom box below this box?
You must be logged in to post a comment.
There are no convenient hooks to add something to that box.
You could do one of two things.
1. Add a new Meta Box
You do this by hooking into the
add_meta_boxes
action and callingadd_meta_box
. You can specify a callback function in your call to add_meta_box. That callback will take care of echoing out your select list.2. Remove the Default Page attributes meta box, add your own version
All the content on the post editting screen, with the exception of the main editor and title area, is a meta box. You can remove them by calling
remove_meta_box
, then replace them with your own.So, first up, modify the add function above to include a remove meta box call. Then you’ll need to copy the
page_attributes_meta_box
function body fromwp-admin/includes/meta-boxes.php
and put your stuff below it.Either way you do this, you’ll need to hook into
save_post
to save the value of your field withadd_post_meta
and/orupdate_post_meta
.This tutorial might help you out.
Woohoo! As of WP 4.9.0, there is an action hook to add code to the Page Attributes meta box:
'page_attributes_misc_attributes'
. See the Codex for reference.Example: