before i invent the wheel again... i need a select box in the frontend where the user can search and select an extensive post-collection. i was looking at select2, and noticed, that you guys use also select2 for post-select (see image, i need exactly this functionality).
is there any way toolset can support me in showing a select-box like this in the front-end? or do i just have to include select2 myself and build it myself?
If it is not in a context where select2 is already included on the page (e.g. a form with a parent post selector) then you will need to manually enqueue the select2 assets.
You could create a View which a list of posts as a select dropdown and then instantiate select2 to convert it, but what are you going to be using this dropdown for?
You can't, for example, filter Views by standard posts like the post title.
It's an administrative extension on a website where data is entered / collected in the frontend of wordpress. (a newsletter template).
There are input-boxes where the editor can select a post. currently the user enters the post-id and the system gets the post via ajax.
i would like to replace this lookup with a more comfortable aproach where the user enters searchstring and has a dynamic dropdown-list. i need EXACTLY what you got you in the posts-dropdown of the screenshot - a dropdown in a modal. so i was wondering, if there is a way to "invoke" this myself in the frontend.
or as you say: simply enqueue the assets myself and implement select2 and the functionality i need from scratch.
but since you got already exactly what i need as a standard-dialog in the backend, i was hoping there's a way to hook into that functionality in the frontend and in my own code.
A front-end form to publish a child post would have a parent post selector that works in the same way as your screenshot from a backend parent post edit screen, but it is not possible to extract that to be used elsewhere, you will have to set it up yourself.
But as I mentioned before you should be able to make a View that lists the posts and which outputs them as a select input (unusual, but I expect it would work) where the options are generated by the loop, insert the View where needed on a front-end page, and trigger select2 to convert the input from a standard dropdown.