Comments (1)
Sorry this took so long for me to get around to looking at.
Attachments are given post_status
= inherit
by default. So add that line and you should be good to go.
add_action( 'pre_get_posts', 'category_attachments' );
function category_attachments( $wp_query ) {
if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) ) {
$wp_query->set( 'post_type', array('attachment') );
$wp_query->set( 'post_status', 'inherit' );
}
}
The reason is just that WordPress handles attachments differently, in your case if you look at the request
SQL, you'll notice that WP_Query by default sets post_status
to publish
. This returns nothing because media doesn't go through the draft->published life cycle.
from media-categories.
Related Issues (20)
- Test 1.6 in WordPress 3.7
- Test 1.6 in WordPress 3.8
- Filter items in Media Library by taxonomy term
- Test 1.6 in WordPress 3.4
- Taxonomy counts are incorrect. HOT 1
- Filter media modal by taxonomy terms
- Media Modal - Dropdown taxonomy filters get cleared after first selection
- Sortable columns not sorting
- Media Library: SQL Errors when dropdown filter and sorted columns are used at the same time.
- Media Modal "Metafauxes" glitch open after save.
- Column sorting not sorting properly
- Test in WordPress 3.6 HOT 1
- Test Gallery Shortcode in WordPress 3.4 throigh 3.8
- Test Media Categories 1.6 in WordPress 3.9 (Betas)
- Gallery Shortcodes not functioning with multiple custom taxonomies
- 'mc_taxonomy' filter not working properly
- Media Library drop down filter not showing if taxonomy doesnt have posts in one of its terms
- Metaboxes not functioning properly when using a non-hierarchical taxonomy
- PHP Strict Standards: Declaration of Attachment_Walker_Category_Checklist:
- Media_Categories::enqueue_media_categories_scripts() should not be called statically
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media-categories.