[wp-trac] [WordPress Trac] #15323: Filter by post format in wp-admin/edit
WordPress Trac
noreply at wordpress.org
Thu Jan 17 17:16:05 UTC 2013
#15323: Filter by post format in wp-admin/edit
----------------------------+-----------------------------
Reporter: PeteMall | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Administration | Version: 3.1
Severity: normal | Resolution:
Keywords: needs-patch |
----------------------------+-----------------------------
Comment (by beaulebens):
FWIW, here's what I'm currently using in a theme I'm working on:
{{{
function homeroom_manage_posts_formats( &$wp_query ) {
if ( !is_admin() )
return;
if ( function_exists( 'get_current_screen' ) && $screen =
get_current_screen() ) {
if ( is_object( $screen ) && 'post' !== $screen->post_type
)
return;
}
if ( empty( $_REQUEST['format'] ) )
return;
$post_format_tax_query = array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => 'post-format-' . esc_attr(
$_REQUEST['format'] ),
'operator' => 'IN'
);
$tax_query = $wp_query->get( 'tax_query' );
if ( is_array( $tax_query ) ) {
$tax_query = $tax_query + $post_format_tax_query;
} else {
$tax_query = array( $post_format_tax_query );
}
$wp_query->set( 'tax_query', $tax_query );
}
add_action( 'pre_get_posts', 'homeroom_manage_posts_formats' );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15323#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list