WP Query group/order by category name

There are a few ways you can do this. The simplest is to just get everything: posts and terms, then use some array_filter magic to group things. Simple example (that will only work with PHP 5.3+): <?php $terms = get_terms(‘your_taxonomy’); $term_ids = array_map(function($t) { return $t->term_id, }, $terms); $posts = get_posts(array( ‘nopaging’ => true, ‘tax_query’ … Read more

add_meta_box: Datepicker like the one for postdate?

Never really thought about it, but it should indeed be a good option. The date picker is called from wp-admin/includes/meta-boxes.php (line 183) as: <div id=”timestampdiv” class=”hide-if-js”><?php touch_time(($action == ‘edit’),1,4); ?></div> and touch_time() is defined in wp-admin/includes/template.php (line 550) as: /** * {@internal Missing Short Description}} * * @since 0.71 * * @param unknown_type $edit * … Read more

Include both default and Custom Post Type in query modified inside pre_get_posts

As Kaiser mentioned, the post_type parameter can accept an array of post types. Updating the function to use is_main_query() to limit the filter to only the “main” query, the code would look like: add_action( ‘pre_get_posts’, ‘custom_post_author_archive’ ); function custom_post_author_archive( $query ) { if ( is_main_query() && is_author() ) { set_query_var( ‘post_type’, array(‘post’,’custom_post’) ); } }