如何在循环中返回自定义帖子?我读了几篇关于同一主题的文章,但没有直接的内容。我有一个显示常规帖子的博客,我有自定义帖子“广告”。我喜欢开始在循环中显示最新的自定义帖子。最终结果可以是只返回自定义帖子的循环。
<?php if ( ! have_posts() ) : ?>
<div id="post-0" class="post not-found item-list">
<h2 class="entry-title"><?php _e( \'Not Found\', \'tie\' ); ?></h2>
<div class="entry">
<p><?php _e( \'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.\', \'tie\' ); ?></p>
<?php get_search_form(); ?>
</div>
</div>
<?php else : ?>
<?php
$count = 0;
$post_width = tie_post_width();
$exc_home_cats = tie_get_option( \'exc_home_cats\' );
if( is_home() && $exc_home_cats ) query_posts( array( \'advert\',\'category__not_in\' => $exc_home_cats , \'paged\' => $paged) ); ?>
<?php while ( have_posts() ) : the_post(); $count++;
$color = \'\';
$get_meta = get_post_custom($post->ID);
$tie_post_color = $get_meta["tie_post_color"][0];
if( !empty($tie_post_color)) $color =\'custom-color \'.$tie_post_color;
?>
<article <?php post_class(\'item-list post rtl-item \'.$color.\' \'.$post_width) ?>>
<div class="post-inner">
<?php
$format = get_post_format();
if( false === $format ) { $format = \'standard\'; }
?>
<?php get_template_part( \'content\', $format ); ?>
</article><!-- .item-list -->
<?php endif; ?>
谢谢你的帮助!