admin管理员组文章数量:1290785
I have post_type called 'series' and posts with sharing category as attachment. The problem is when I create list using post_type by date, the date follows post_type post date and not latest 'post'. How can I change that automatically?
<?php $paged = get_query_var("paged") ? get_query_var("paged") : 1; $chapter = new WP_Query(array("post_type" => "series", "posts_per_page" => 12, "orderby" => "date", "paged" => $paged)); if ($chapter->have_posts()) { while ($chapter->have_posts()) { $chapter->the_post(); get_template_part('template-parts/content', 'index'); } } ?>
From template part
<div class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div>
<ul class="chapter">
<?php $title = basename(get_permalink()); $chapter = new WP_Query(array("showposts" => 1, "post_type" => "post", "tax_query" => array(array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => $title,),), "no_found_rows" => true, "update_post_term_cache" => false, "update_post_meta_cache" => false, "cache_results" => false)); if($chapter->have_posts()){ while ($chapter->have_posts()) { $chapter->the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a><span class="date"><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?> </span>
本文标签: How to set post date in posttype so that it39s same as latest post in category
版权声明:本文标题:How to set post date in post_type so that it's same as latest post in category 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741514871a2382823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论