I’m using Types plugin for create a WordPress Custom Post Type (CPT), now I need to display that content. I have created a page called: category-legislaciones.php
where legislaciones
is the category, from the CPT itself, created using Types plugin. This is the code I have on that page:
<?php
$args = array( 'post_type' => 'legislaciones', 'posts_per_page' => 15 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<h1 class="post-title"><?php the_title(); ?></h1>
<?php $options = get_option( 'responsive_theme_options' ); ?>
<?php if ( $options['breadcrumb'] == 0 ): ?>
<?php echo responsive_breadcrumb_lists(); ?>
<?php endif; ?>
<div id="post-<?php the_ID(); ?>">
<div class="post-entry">
<?php the_content( __( 'Read more ›', 'responsive' ) ); ?>
<?php wp_link_pages( array(
'before' => '<div class="pagination">' . __( 'Pages:', 'responsive' ),
'after' => '</div>'
)); ?>
</div>
<?php if ( comments_open() ) : ?>
<div class="post-data">
<?php the_tags( __( 'Tagged with:', 'responsive' ) . ' ', ', ', '<br />' ); ?>
<?php the_category( __( 'Posted in %s', 'responsive' ) . ', ' ); ?>
</div><!-- end of .post-data -->
<?php endif; ?>
<div class="post-edit"><?php edit_post_link( __( 'Edit', 'responsive' ) ); ?></div>
</div><!-- end of #post-<?php the_ID(); ?> -->
<?php comments_template( '', true ); ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<?php if ( function_exists( 'wp_paginate' ) ) {
wp_paginate();
} ?>
<?php endif; ?>
<?php get_search_form(); ?>
<?php endwhile; ?>
But nothing is display even if I have content assigned to that category, what I am doing wrong? What is the right way to display that contents?
It looks like you are mixing
Custom Post Type (post_type => ‘post_type’ => ‘legislaciones’)
and Custom Taxonomy,
or do you really have both Custom Post Type and Custom Taxonomy with the same slug ?
If your legislaciones is a Custom Post Type, the proper name for your file would be archive-legislaciones.php and you don’t need a specific query
If your legislaciones is a Custom Taxonomy, then here you are basically calling for the posts with post_type legislaciones and the Taxonomy legislaciones with a value which would be determined in the url
This is all detailed in the Codex, the page about Template Hierarchy
It does not belong to your question, but your code will repeat breadcrumb and comment form 15 times on the page, is this really what you want ?