Created
April 1, 2015 09:40
-
-
Save romuloctba/1352d85a160440af20b1 to your computer and use it in GitHub Desktop.
Include all post types in archive page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function archiveAll( $query ) { | |
| if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
| $query->set( 'post_type', array( | |
| 'post', 'myCustomPostSlugHere' | |
| )); | |
| return $query; | |
| } | |
| } | |
| add_filter( 'pre_get_posts', 'archiveAll' ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This solves the problem with, for example, the 'categories widget', that shows the total count of posts, but only list the post-type 'post' in the archive page. ;) Nice
by csstricks.com