Skip to content

Instantly share code, notes, and snippets.

@harisrozak
Last active August 29, 2015 14:06
Show Gist options
  • Save harisrozak/8b33292e748d6f1af21f to your computer and use it in GitHub Desktop.
Save harisrozak/8b33292e748d6f1af21f to your computer and use it in GitHub Desktop.
WordPress :: Make Archives.php Include Custom Post Types
<?php
add_filter('pre_get_posts', 'namespace_add_custom_types');
function namespace_add_custom_types( $query ) {
if( !is_admin() && is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'nav_menu_item', 'your-custom-post-type-here'
));
return $query;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment