如何获取多友文章类型存档?

时间:2018-11-19 12:07:14

标签: php wordpress custom-post-type

我想获取多类自定义帖子类型的档案,您能帮我吗,这是我的代码不起作用

_

1 个答案:

答案 0 :(得分:0)

尝试一下:

<?php

$args = array(
    'post_type'    => array('news','update'),
    'post_status'  => 'archive',
    'type'         => 'monthly',
    'echo'         => 0,
    'order'        => 'DESC'
);

$query = new WP_Query( $args );


// Check that we have query results.
if ( $query->have_posts() ) {

    // Start looping over the query results.
    while ( $query->have_posts() ) {

        $query->the_post();

        ?>

        <article id="post-<?php the_ID(); ?>" >
            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                <?php post_thumbnail( 'thumbnail' );?>
            </a>
            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
                <?php the_title(); ?>
            </a>
            <?php the_excerpt(); ?>
        </article>

        <?php

    }

}

// Restore original post data.
wp_reset_postdata();