Questo codice mi mette le categorie di appartenenza nelle anteprime delle pagine, ma vorrei modificarlo per far si che le categorie di appartenenza si mostrassero anche nelle anteprime degli articoli Wordpress.
Codice PHP:
function add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'category', 'page' );
}
// Mostra le categorie nelle anteprime delle pagine
add_action( 'init', 'add_taxonomies_to_pages' );
add_action( 'pre_get_posts', 'category_preview' );
// Aggiunge la pagina come post_type in archive.php
function category_preview( $wp_query ) {
if( $wp_query->is_main_query() && ! is_admin() && ( $wp_query->is_category())) {
$my_post_array = array('post','page');
if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
$wp_query->set( 'post_type', $my_post_array );
}
}