wp-shortcake / shortcake

Shortcake makes using WordPress shortcodes a piece of cake.
GNU General Public License v2.0
664 stars 143 forks source link

Show post type in post_select field #735

Closed grappler closed 7 years ago

grappler commented 7 years ago

Related to #627

I have been using post_select for a client and they we were querying posts from two post types. The posts in both post types had the same titles. There was no way to differentiate between the two posts.

image

Customize Object Selector has a feature where it shows the post type. image

Beitrag = Post Inhaltselement = Content Block (CPT)

goldenapples commented 7 years ago

Good suggestion, and I like the fix you proposed for it (showing the post type object label in parentheses if more than one post type is being queried).

In order to accommodate more customization of the templated results (for requests like #627, where the idea of adding the post featured image to the dropdown was proposed), we might have to add a filter in the loop that handles the formatting of each post in the ajax return value - because it would be a two-part process, returning additional fields for each post in the ajax response, and then defining a templateSelection method on the select2 field to render it.

This is a good fix for the basic requirement here, though.

grappler commented 7 years ago

Perhaps we can think about adding support for post statuses too. term_select could profit from some of these changes too.

Good suggestion, and I like the fix you proposed for it (showing the post type object label in parentheses if more than one post type is being queried).

I can't take all of the credit. Got my inspiration from @westonruter

goldenapples commented 7 years ago

term_select could profit from some of these changes too.

Yeah, that follows the same pattern as post type -- maybe just including the taxonomy name in parentheses when more that one taxonomy is queried -- and would make sense to tackle in the same way.

Perhaps we can think about adding support for post statuses too.

I think that might be adding too much information to an unstructured UI. I've worked on setups where that would be helpful, but it would be hard to make that decision from the plugin. Maybe something that might be better done by adding a filter?