I have three page templates, homepage, documentary, and corporate, each using the same CPT WP_query code with only the category name changed for each respectively. The homepage works fine, pulling and showing the correct category of my CPT. The other two do not work.
Here is a snippet of the code for the homepage:
<?php
/*
Template Name: Homepage Reels
*/
/*
@package _tk
*/
get_header(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<div class="container-fluid">
<?php $args = array( 'post_type' => 'films',
'tax_query' => array(
array(
'taxonomy' => 'film-type',
'field' => 'slug',
'terms' => 'homepage',
)
),
'posts_per_page' => '-1', );
$the_query = new WP_Query( $args ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php /* Get the current post ID. */
$post_id = get_the_ID();
/* If we have a post ID, proceed. */
if ( !empty( $post_id ) ) { ?>
<div class="film_wrap col-md-4">
<?php // <h2 class="film_title"><?php the_title(); ?><?php //</h2> ?>
<?php $videourl = get_post_meta( $post_id, 'film_embed', true );
if ( $videourl != '' ) {
echo wp_oembed_get( $videourl );
} ?>
<?php if ( get_post_meta( $post_id, 'film_textarea', true ) ) : ?>
<div class="film_description">
<p><?php echo get_post_meta( $post_id, 'film_textarea', true ); ?></p>
</div>
<?php endif; ?>
</div>
<?php } else { ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php } ?>
<?php wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', '_tk' ),
'after' => '</div>',
) ); ?>
<?php endwhile; ?>
<?php endif; ?>
and the documentary template:
<?php
/*
Template Name: Documentary Reels
*/
/*
@package _tk
*/
get_header(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<div class="container-fluid">
<?php $args = array( 'post_type' => 'films',
'tax_query' => array(
array(
'taxonomy' => 'film-type',
'field' => 'slug',
'terms' => 'documentary',
)
),
'posts_per_page' => '-1', );
$the_query = new WP_Query( $args ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php /* Get the current post ID. */
$post_id = get_the_ID();
/* If we have a post ID, proceed. */
if ( !empty( $post_id ) ) { ?>
<div class="film_wrap col-md-4">
<?php // <h2 class="film_title"><?php the_title(); ?><?php //</h2> ?>
<?php $videourl = get_post_meta( $post_id, 'film_embed', true );
if ( $videourl != '' ) {
echo wp_oembed_get( $videourl );
} ?>
<?php if ( get_post_meta( $post_id, 'film_textarea', true ) ) : ?>
<div class="film_description">
<p><?php echo get_post_meta( $post_id, 'film_textarea', true ); ?></p>
</div>
<?php endif; ?>
</div>
<?php } else { ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php } ?>
<?php wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', '_tk' ),
'after' => '</div>',
) ); ?>
<?php endwhile; ?>
<?php endif; ?>
I have no errors via WP_DEBUG. Here is the testing site: http://thegallerymusic.com/test/
Can't think of what could possibly be allowing homepage to work, but causing the documentary/corporate templates to NOT work. Any ideas?
div
s for each post, but the custom_post_meta (the actual video embed, title, description) is not being loaded within those...get_the_ID()
function. Can you add the header where the name of the templates is?