0
I created two "Custom Post Type", with the following names "Movies" and the other "Series", both using the same "Register Taxonomy"".
However when I do a search like for example:
When filter only the genre "Action", the site returns me other posts that do not have the same genre, the system lists all movies and series and ignores the term filtered.
Here is the function of the "Custom Post Type" Movies (The Series and identical, only changes the function parameters, logico kkk)
add_action( 'init', 'post_type_movies' );
function post_type_movies() {
$labels = array(
'name' => __( 'Filme', mundothemes ),
'singular_name' => __( 'Filmes', mundothemes ),
'add_new' => __( 'Adicionar Novo', mundothemes ),
'add_new_item' => __( 'Adicionar Novo Filme', mundothemes ),
'edit_item' => __( 'Editar Filme', mundothemes ),
'new_item' => __( 'Novo Filme', mundothemes ),
'all_items' => __( 'Todos os Filmes', mundothemes ),
'view_item' => __( 'Ver Filme', mundothemes ),
'search_items' => __( 'Pesquisar Filme', mundothemes ),
'not_found' => __( 'Nenhum filme encontrado', mundothemes ),
'not_found_in_trash' => __( 'Nenhum filme na lixeira', mundothemes ),
'menu_name' => __( 'Filmes', mundothemes ),
);
$supports = array( 'title', 'editor', 'thumbnail', 'comments');
$slug = get_theme_mod( 'movies_permalink' );
$slug = ( empty( $slug ) ) ? 'filmes' : $slug;
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $slug ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 4,
'supports' => $supports,
'menu_icon' => 'dashicons-editor-video',
);
register_post_type( 'filmes', $args );
}
Here is the function of the "Register Taxonomy" Genus (This function I use in both Custom Post Type)
add_action( 'init', 'custom_taxonomy_genre', 0 );
function custom_taxonomy_genre() {
register_taxonomy(
'genero', // COLOCAR EM PT-BR
array('series','filmes'), // DEFINE O TIPO DE POST - CUSTOM POST TYPE
array( 'hierarchical' => true, 'label' => 'Gênero', 'query_var' => true, 'rewrite' => true )
);
}
I do not know the reason for this error, is that there is to add something more to the function or the reason and other?
Could you provide more details? For example, how is the call to methods made. Because the question does not seem to meet the requirements of Minimum, Complete and Verifiable Example
– Jhonatan Pereira
Let’s say I click on a link with the term "action", then I am redirected to: "http://localhost/genero/acao/" but instead of the system filter the posts that have the same term, which would be "action", the page returns me all the posts of the site, ignoring the search term.
– Vitor Hugo
in theory I have already solved my problem, however if anyone has a better solution than this, please share. I solved it as follows, I created a file called "taxonomy-genero.php", copied the same index code, but removed the array that filtered the two custom post type, leaving only "<? php if ( have_posts() ) while ( have_posts() ) the_post(); ? >", the downside is that I currently have 10 taxonomy, that is, I will have to create 10 pages with the name "taxonomy-{taxonomy}. php".
– Vitor Hugo
again solved my kkkk problem, just removed the name "genero" leaving the file so "taxonomy.php" and solved, there are times that I think q am a genius or very dumb even rs.
– Vitor Hugo
Hahahaha I was going to suggest Inheritance of Objects
– Jhonatan Pereira
it was so simple, and I spent the whole morning cracking my head with it.
– Vitor Hugo