0

I have a custom plugin page and I want users to be able to select posts/pages and add them to a list.

I was hoping to use the same UI as found on the Appearance > Menus Page which I picture below

Desired UI

Is there a function to specifically print this UI into the page?

1
  • Thomas, I'm not sure if this does exist as I've never actually checked, but in instances like this I usually use Select2 inputs where the user starts typing and once there's at least 3 letters an AJAX search starts executing and returns matching results. Feb 17, 2021 at 18:50

1 Answer 1

0

No, there's no existing function available for an equivalent UI for posts or pages.

The whole UI in your screenshot is provided by the post_categories_meta_box() function, which uses wp_category_checklist() internally for the actual checkboxes, which implements the Walker_Category_Checklist class. All of these are built for listing terms as checkboxes, and can't be repurposed for listing posts.

You would need to implement this yourself (although if you look at the source for post_categories_meta_box() you might be able to use matching markup to ensure visual consistency.

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.