lp__term_menu_order
lp__term_menu_order is a custom query parameter in the Launchpad plugin that allows ordering posts based on term associations within a specific taxonomy.
Product
How it Works
When querying posts, WordPress allows ordering by post meta but does not natively support ordering by term meta within a taxonomy. lp__term_menu_order extends WordPress query capabilities by modifying the JOIN clause to include term relationships, taxonomy, and term meta.
This enables ordering posts based on the menu_order meta key of their associated terms within a specified taxonomy. If no menu_order is set for a term, a default value of 9999 is used to ensure consistent ordering.
Accepted Values
- taxonomy (string) – The taxonomy whose terms determine the post ordering.
Usage
When included in a query, lp__term_menu_order modifies the JOIN clause to connect the posts table with term relationships, taxonomy, and term meta. This allows ordering posts based on the menu order of their associated terms.
Example
$args = array(
'post_type' => 'rep_employee',
'lp__term_menu_order' => 'rep_employee_cat', // Replace with your actual taxonomy.
'orderby' => 'lp__term_menu_order',
'order' => 'ASC',
);
$query = new WP_Query( $args );
In this example, the query:
- Orders
rep_employeeposts based on themenu_ordervalue associated with terms in therep_employee_cattaxonomy. - Defaults to
9999if nomenu_ordervalue is found for a term.
Result
| This query retrieves posts associated with terms in the specified taxonomy while applying ordering based on term menu order. This is useful for cases where terms influence how posts should be displayed. |