I have several custom posts types (albums, reviews, filmes and livros). On the index.php there's a loop where I need to show all of that content, with a "load more posts".
Here's how it looks right now:
The problem is, I can't get the "post" post type to work. I'm using conditional tags to give write whatever I want in each one of them, but when I tried to do the same with posts, none of the exemples I've found worked.
Here's how the normal posts looks like: image 2
There will be a lot more of them then these custom post types.
Each post type has it's own information I need to display. The printscreen is to have an idea of what it all looks like. Even better: here's the code.
<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> Carregar mais posts</button>
</section>
So, does anyone know how to help me, pretty please? :)
If I understand correctly, your code is working perfectly fine with the exception of displaying posts with the post type of post
.
is_singular()
checks to see if the current page is a single page
, post
, or attachment
, but it doesn't check the post type. See more here.
Have you tried using the same get_post_type()
check?
<?php if ( 'post' == get_post_type() ) { ?>
Let me know if I'm misunderstanding something here.