WordPress Snippet
I was tasked with alphabetizing the archive of a custom post type using an off-the-shelf theme. The theme's archive.php file used the global variable global $wp_post
to set the query.
The example here was placed in a custom post type archive (archive-example.php) following the global variable to merge with the default query. One can use this with any of the query variables.
Note: This will fail for
meta_query
andtax_query
. Also arrays such astag_slug__and
should be merged + special values such asany
forpost_type
need to be handled correctly. For these you need something like: