Problems with the WP_Query query for a Custom post type

1

Good afternoon, I have the following problem with the consultation of my CPT, I want you to show me the type of post, the taxonomy "courses" and the last 3 post. The query is done correctly until the taxonomy, it shows me the post of all the taxonomies (courses).

here is the code:

The query:

        <?php 

        $the_query = new WP_Query( array(
            'post_type'         =>  'circulares',
            'posts_per_page'    =>  2,
            'tax_query'         =>  array(
                'taxonomy'      =>  'curso',
                'field'         =>  'slug',
                'terms'         =>  'tercero',
            ),
        ));


        while ( $the_query->have_posts() ) :
        $the_query->the_post(); ?>

        <?php the_title(); ?><br>

        <?php endwhile;


        wp_reset_postdata(); ?>

the registration of the taxonomy:

        add_action( 'init', 'create_circular_taxonomies', 0 );


    function create_circular_taxonomies() {

            $labels = array(
            'name' => _x( 'Cursos', 'taxonomy general name' ),
            'singular_name' => _x( 'Curso', 'taxonomy singular name' ),
            'search_items' =>  __( 'Buscar por Curso' ),
            'all_items' => __( 'Todos los Cursos' ),
            'parent_item' => __( 'Curso padre' ),
            'parent_item_colon' => __( 'Curso padre:' ),
            'edit_item' => __( 'Editar Curso' ),
            'update_item' => __( 'Actualizar Curso' ),
            'add_new_item' => __( 'Añadir nuevo Curso' ),
            'new_item_name' => __( 'Nombre del nuevo Curso' ),
    );

register_taxonomy( 'curso', array( 'circulares' ), array(
        'hierarchical' => true,
        'labels' => $labels, 
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'cursos' ),
));

}

The registration of the Custom post type

add_action( 'init', 'circulares');

function circulares() {
    $labels = array(
        'name'              => _x( 'Circulares', 'post type general name' ),
        'singular_name'     => _x( 'Circular', 'post type singular name' ),
        'add_new'           => _x( 'Añadir nueva', 'circular' ),
        'add_new_item'      => __( 'Añadir nueva circular' ),
        'edit_item'         => __( 'Editar circular' ),
        'new_item'          => __( 'Nueva circular' ),
        'view_item'         => __( 'Ver circular' ),
        'search_item'       => __( 'Buscar circulares' ),
        'not_found'         => __( 'No se han encontrado circulares' ),
        'not_found_in_trash'=> __( 'No se ha encontrado circulares en la papelera' ),
        'parent_item_colon' => ''                   
    );



    $args = array( 
        'labels'                => $labels,
        'public'                => true,
        'publicly_queryable'    => true,
        'show_ui'               => true,
        'query_var'             => true,
        'rewrite'               => true,
        'capability_type'       => 'post',
        'hierarchical'          => false,
        'menu_position'         => null,
        'supports'              => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
    );  



    register_post_type( 'Circulares', $args );
}
    
asked by DCdesign 17.11.2016 в 20:33
source

0 answers