Post types by taxonomies

0

I'm doing it that way and still, it's not pulling the taxonomy I want. It's pulling WP's standard posts and not mine specifically.

My post type is 'post_type' = > 'posts_blog', as below and the taxonomy of this post is categ_blog_home, and in this taxonomy I have posts_antigos there and even passing code below, I can not pull it.

                <?php 
                    $args = array(
                        'post_type' => 'posts_blog',
                        'status' => 'publish',
                        'numberpost' => 4,

                        'tax_query' => array(
                            'taxonomy' => 'categ',
                            'terms' => 'posts-testes',
                        )
                    );
                    $query = new WP_Query( $args );
                 ?>

                <?php 
                    if (have_posts()) : 
                        foreach( $query as $post ) : setup_postdata ( $post );?>     
                            <div class="all-posts-antigos">

                                <div class="block-thumb">
                                    <?php the_post_thumbnail(); ?>
                                </div>

                                <div class="block-infos">
                                    <h1><?php the_title(); ?></h1>
                                    <h3><?php the_author_posts_link(); ?></h3>
                                    <span><?php the_time("d/m/Y"); ?></span>
                                    <p><?php the_content(); ?></p>
                                    <?php get_taxonomies( $args, $output, $operator ) ?>
                                </div>

                            </div>
                        <?php  
                    endforeach; 
                    else:
                        echo '<p class="bg-warning">Nenhum post foi encontrado.</p>';
                endif; ?>
            </div>>
    
asked by anonymous 15.04.2017 / 01:33

1 answer

0

You have some errors in your code, try the fixes below:

                <?php 
                $args = array(
                    'post_type' => 'posts_blog',
                    'status' => 'publish',
                    'numberpost' => 4,

                    'tax_query' => array(
                        'taxonomy' => 'categ',
                        'terms' => 'posts-testes',
                    )
                );
                $query = new WP_Query( $args );
             ?>

            <?php 
                if ($query->have_posts()) : 
                    while ($query->have_posts()) : $query->the_post();?>     
                        <div class="all-posts-antigos">

                            <div class="block-thumb">
                                <?php the_post_thumbnail(); ?>
                            </div>

                            <div class="block-infos">
                                <h1><?php the_title(); ?></h1>
                                <h3><?php the_author_posts_link(); ?></h3>
                                <span><?php the_time("d/m/Y"); ?></span>
                                <p><?php the_content(); ?></p>
                            </div>

                        </div>
                    <?php  
                    endwhile; 
                else:
                    echo '<p class="bg-warning">Nenhum post foi encontrado.</p>';
                endif; 
                wp_reset_postdata();
            ?>
        </div>
    
15.04.2017 / 18:05