我有密码。它可以工作,但并不完美:每个网站都有一个类别;通知”;但不显示按最新日期排序的帖子,只显示为一个序列(博客1:3按日期排序的帖子,博客2:3按日期排序的帖子,博客3:3按日期排序的帖子,等等),我想一起显示。
网站:黄色来自博客2-3
代码$blog_ids = array( 1, 2, 3, );
foreach( $blog_ids as $id ) {
switch_to_blog( $id );
$args = array(
\'category_name\' => \'noticias\',
\'post_status\' => \'publish\',
\'orderby\' => \'publish_date\',
\'order\' => \'DESC\',
\'posts_per_page\' => \'4\',
);
$query = new WP_Query( $args );
if( $query->have_posts() ) :
while( $query->have_posts()) : $query->the_post() ;
?>
<div class="col-md-3 mb-36">
<div class="uc-card card-height--same">
<span class="tag-fixed"><?php $tags = get_the_tags($post->ID); ?>
<?php foreach($tags as $tag) : ?><a class="uc-tag" href="<?php bloginfo(\'url\');?>/tag/<?php print_r($tag->slug);?>"><?php print_r($tag->name); ?></a> <?php endforeach; ?></span>
<div class="uc-card_body">
<p class="p-size--sm p-color--gray p-text--condensed"><?php //the_date();?></p>
<h4><?php the_title(); ?></h4>
<div class="uc-text-divider divider-primary my-20"></div>
<div class="mt-auto">
<a href=" <?php echo get_permalink(); ?> " class="uc-btn btn-inline">
Ver más
<i class="uc-icon">keyboard_arrow_right</i>
</a>
</div>
</div>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
restore_current_blog();}
我希望你能帮助我,问候!