admin管理员组

文章数量:1302913

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

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

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

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

Share Improve this question asked Feb 17, 2021 at 18:18 Thomas HarrisThomas Harris 1431 silver badge5 bronze badges 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. – Tony Djukic Commented Feb 17, 2021 at 18:50
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: wp adminFunction to get a 39post selector39 UI