Skip to content

Instantly share code, notes, and snippets.

View reneegade's full-sized avatar

Renee Martin reneegade

  • Brisbane
View GitHub Profile
@chrisguitarguy
chrisguitarguy / archive-menu-order.php
Created August 28, 2012 20:16
Force orderby to `menu_order` on a custom post type archive and a few custom taxonomy archives
<?php
add_action('parse_query', 'pmg_ex_sort_posts');
/**
* Hooked into `parse_query` this changes the orderby and order arguments of
* the query, forcing the post order on post type archives for `your_custom_pt`
* and a few taxonomies to follow the menu order.
*
* @param object $q The WP_Query object. This is passed by reference, you
* don't have to return anything.
* @return null
<?php $args = array(
'numberposts' => -1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'custom_post_type_here',
'post_status' => 'draft',
'meta_query' => array(
array(
'key' => 'custom_field_key_name',