CMB2-Post-Search-field
CMB2-Post-Search-field copied to clipboard
Include archive URLs in found select options.
Currently it's not possible to select "pages" like an post archive page. Any way to accomplish this?
Sure it is, use the 'post_type' field parameter like in the example in the readme, but replace 'post' with 'page'.
Sorry for not describing this more clearly in my initial post. I meant an archive page as in the "system" archive page for i.e.: posts (archive.php), or CPT (archive-{post_type}.php).
I guess the problem is these are not really registered with an post id.
If I'm following correctly, those would just be the template files chosen to display the results of the query made for that archive. Not quite sure how they'd tie into this search field extension in this case.
The creative solution we've come up with to this issue is to create link format pages that are basically a redirect over to the archive page URL. We can then select the link page and it acts like a pointer over to the CPT archive page.
Ahhh, @clovepod clued me in on what @sebask was looking for. They wanted to be able to select archive URL from the dropdown.
Indeed, we often use those pages to display all post in our custom post types. Btw, Wordpress does show these archive pages in the Menu selector (see screenshot). Maybe that could be useful.

@clovepod Thanks! Sounds like a great quick fix.
The biggest hickup I could potentially see is that the field returns IDs, not archive urls. May get a bit hairy trying to juggle between the display types and also saving of the intended option between the two possible values.