每种自定义帖子类型 + 原始帖子类型的不同代码'posts'



我有几种自定义帖子类型(专辑,评论,电影和Livros)。在index.php上,有一个循环,我需要在其中显示所有内容,并带有"加载更多帖子"。

这是现在的外观:

图像1

问题是,我无法获得"帖子"帖子类型的工作。我正在使用有条件的标签来写我想要的任何东西,但是当我尝试使用帖子做同样的事情时,我发现的一个例子都没有工作。

这是普通帖子的样子:图像2

这些自定义帖子类型将还有更多。

每个帖子类型都有我需要显示的信息。印刷屏幕是要了解一切的外观。更好的是:这是代码。

      <section id="moreposts">
    <h3>Leia mais</h3>
    <div class="row" data-masonry='{ "itemSelector": ".col-md-3" }'>
            <?php $temp_query = clone $wp_query; ?><?php query_posts("showposts=12&post_type=any"); ?>
            <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
            <?php if ( is_singular('post') )  { ?>
                post type POST
            <?php } ?>
            <?php if ( 'reviews' == get_post_type() ) { ?>
                post type REVIEWS
            <?php } ?>
            <?php if ( 'album' == get_post_type() ) { ?>
                post type ALBUM
            <?php } ?>
            <?php if ( 'filmes' == get_post_type() ) { ?>
                post type FILMES
            <?php } ?>
            <?php if ( 'livros' == get_post_type() ) { ?>
                post type LIVROS
            <?php } ?>
            <?php endwhile; ?><?php endif; ?><?php $wp_query = clone $temp_query; ?><?php wp_reset_query(); ?>
    </div>
            <button href="#fakelink" class="btn btn-block btn-lg btn-round btn-danger"><i class="fa fa-plus"></i>&nbsp;&nbsp; Carregar mais posts</button>
  </section>

那么,有人知道如何帮助我吗?:)

如果我正确理解,则您的代码正常工作,除了显示帖子类型post的帖子外,

is_singular()检查当前页面是单个pagepost还是attachment,但未检查帖子类型。在这里查看更多。

您是否尝试过使用相同的get_post_type()检查?

<?php if ( 'post' == get_post_type() ) { ?>

让我知道我是否在这里误解了一些东西。

最新更新