Как получить многопользовательский архив почтовых типов? - PullRequest
0 голосов
/ 19 ноября 2018

Я хочу получить архивы с несколькими типами записей. Можете ли вы мне помочь, ребята, вот мой код, который не работает

 <?php $args = array(

    'type'            => 'yearly',

    'limit'           => '',

    'format'          => 'custom ', 

    'before'          => '',

    'after'           => '',

    'show_post_count' => false,

    'echo'            => 1,

    'order'           => 'DESC',

    'post_type'     => array('news','update')

);

wp_get_archives( $args ); 

1 Ответ

0 голосов
/ 19 ноября 2018

Попробуйте:

<?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();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...