Skip to content

Instantly share code, notes, and snippets.

@luizlopescom
Last active June 1, 2020 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizlopescom/dd5966d81c632422a219cbfb3069a4f6 to your computer and use it in GitHub Desktop.
Save luizlopescom/dd5966d81c632422a219cbfb3069a4f6 to your computer and use it in GitHub Desktop.
WordPress Archive - include/display custom post type in archive.php results
// Archive.php only shows content of type 'post'
// This filter include custom post type
function archive_add_custom_post_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'fornecedores', 'produtos' //fornecedores ad produtos are custom post types
));
return $query;
}
}
add_filter( 'pre_get_posts', 'archive_add_custom_post_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment