Last active
June 1, 2020 20:48
-
-
Save luizlopescom/dd5966d81c632422a219cbfb3069a4f6 to your computer and use it in GitHub Desktop.
WordPress Archive - include/display custom post type in archive.php results
This file contains 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
// 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