Advanced custom fields, php variables and displaying content - php

I have an advanced custom field group, and inside the group and inside the group are a few fields and one select field in where the user selects a category. I want to output onto the page based on what category has been chosen.
Here is the code I was trying:
<?php
$limit = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('post_type=Specialist_post&showposts=' . $limit . '&paged=' . $paged);
$wp_query->is_archive = true; $wp_query->is_home = false;
if(have_posts()) :
while(have_posts()) :
the_post();
if(get_field('category') == "1402")
{ ?>
<div class="row wheelsspecial">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h3><?php the_field('company_name'); ?></h3>
<p><?php the_field('brief_description'); ?></p>
<p><?php the_field('contact_number'); ?></p>
<?php the_field('website_address'); ?><br />
<?php the_field('email'); ?>
<?php } else if (get_field('category') == "1403") {?>
<div class="row tuningspecial">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<h3><?php the_field('company_name'); ?></h3>
<p><?php the_field('brief_description'); ?></p>
<p><?php the_field('contact_number'); ?></p>
<?php the_field('website_address'); ?><br />
<?php the_field('email'); ?>
<?php } ?>
<?php
endwhile;
else:
?>
Oops, there are no posts.
<?php
endif;
?>
This now outputs nothing, if i echo the field category its returning 1403, so i would think it at least outputs the else if, maybe this whole code design is wrong. Essentially i want to print different into different divs based on the category selected.

Did it this way, not the ideal solution, works for now, just needs a code review
<div class="row wheelsspecial">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<?php
$args = array(
'numberposts' => -1,
'post_type' => 'Specialist_post',
'meta_key' => 'category',
'meta_value' => '1402'
);
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h3><?php the_field('company_name'); ?></h3>
<p><?php the_field('brief_description'); ?></p>
<p><?php the_field('contact_number'); ?></p>
<?php the_field('website_address'); ?><br />
<?php the_field('email'); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
</div>
</div>
<div class="row tuningspecial">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<?php
$args = array(
'numberposts' => -1,
'post_type' => 'Specialist_post',
'meta_key' => 'category',
'meta_value' => '1403'
);
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h3><?php the_field('company_name'); ?></h3>
<p><?php the_field('brief_description'); ?></p>
<p><?php the_field('contact_number'); ?></p>
<?php the_field('website_address'); ?><br />
<?php the_field('email'); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
</div>
</div>
Thanks all

Related

Wordpress custom pagination links to a blank page

this is my archive of posts: https://polnapol-tarnow.pl/aktualnosci/page/4/
There are only 4 pages but link to another (blank) page is showing up anyway ("Następna strona"). Is there a way to adjust conditions to stop rendering another "Next page" link if there is no another page with posts? I would be very grateful for any help.
Faulty code:
<?php if (!is_paged()) : ?>
<span><?php _e('Next page'); ?> ››</span>
<?php else : ?>
<span><?php _e('Next page'); ?> ››</span>
<?php endif; ?>
Full template:
<?php $b_subitlte = get_field('b_subitlte');
$b_title = get_field('b_title');
$b_desc = get_field('b_desc'); ?>
<section class="blog-home padding czarny">
<?php if ( function_exists('yoast_breadcrumb') ) { ?>
<div class="breadcrumbs">
<div class="container">
<?php yoast_breadcrumb('<p id="breadcrumbs">','</p>'); ?>
</div>
</div>
<?php } ?>
<div class="col-sm-offset-2 col-sm-8 text-center">
<h4 class="upper-title">aktualności</h4>
<h2 class="title">aktywni <br>
nie tylko w kuchni</h2>
<p>nieustannie badamy otaczający świat aby tworzyć nie tylko lepsze potrawy, ale i klimat naszego włoskiego lokalu. Inspirujemy się i piszemy o tym!</p>
</div>
<div class="container">
<div class="row">
<div class="col-sm-offset-2 col-sm-8 text-center">
<h4 class="upper-title"><?php echo $b_subitlte; ?></h4>
<h2 class="title black"><?php echo $b_title; ?></h2>
<p><?php echo $b_desc; ?></p>
</div>
</div>
<?php
$args = array(
'posts_per_page' => 5,
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
);
$news = new WP_Query( $args );
if ( $news->have_posts() ) : ?>
<div class="blog-wrapper row">
<?php while ( $news->have_posts() ) : $news->the_post(); ?>
<?php $blog_short = get_field('blog_short'); ?>
<div class="col-md-4 col-xs-6">
<?php if ( has_post_thumbnail() ) : ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<div style="background-image: url(<?php echo $url; ?>)" class="thumbnail-cover">
<?php the_post_thumbnail($post->ID);?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="custom-hover">
<span class="main-btn">zobacz post</span>
</a>
</div>
<?php endif; ?>
<p class="meta"><?php the_time('Y-m-d'); ?></p>
<h2 class="title">
<?php the_title(); ?>
</h2>
<p><?php echo $blog_short; ?></p>
</div>
<?php endwhile; ?>
</div>
<?php echo previous_posts_link(); ?>
<?php if (!is_paged()) : ?>
<span><?php _e('Nastepna strona'); ?> ››</span>
<?php else : ?>
<span><?php _e('Następna strona'); ?> ››</span>
<?php endif; ?>
<?php endif; wp_reset_postdata(); ?>
</div>
</section>
</div>
You should use the pagination of WordPress. Go to this link: WordPress pagination
You can use this template for your pagination :
<div class="paginate">
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'prev_text' => '<<' ,
'next_text' => '>>' ,
) );
?>
</div>
And you can set a number of the post in one page by going WordPress panel > setting > reading > blog page show at most.
I managed to fix this issue by counting all published posts and dividing them by number of posts per page (in this case 5 posts):
$count_posts = wp_count_posts()-> publish / 5;
So my code was:
<?php echo previous_posts_link(); ?>
<?php if (!is_paged()):?>
<span><?php _e('Previous page'); ?> ››</span>
<?php elseif ($count_posts > $paged ):?>
<span><?php _e('Next page'); ?> ››</span>
<?php else : ?>
<?php endif; ?>

WordPress loop alternate rows and columns each two posts with bootstrap

I want to create a loop for wordpress that returns each two posts inside its own div and alternating columns every new row (see example)... Im not experimented in php enough to make this happen. I dont manage to get it working appropiatly. And see how to make the last div to bee 100% width if it does not have another column.
I would appreciate your support to make this happen since I tried many things and still no luck. (im using visual composer bootstrap classes, it does work but not as expected.This is the example I want to create
This is my code:
<?php
$args = array(
'posts_per_page' => '-1',
'post_type' => 'inversion',
'category_name' => '',
'order' => 'DESC',
'orderby' => 'DATE'
);
$the_query = new WP_Query( $args );?>
<?php if ( $the_query->have_posts() ) : ?>
<div class="vc_row">
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); $i++; $imagen = get_the_post_thumbnail_url(get_the_ID(),'full'); ?>
<?php if(($i % 2) == 2) : ?>
<div class="vc_col-sm-6">
<div class="vc_row vc_row-fluid">
<div class="vc_col-sm-6 cont-izq">
<h3><?php the_title(); ?></h3>
</div>
<div class="vc_col-sm-6 cont-der" >
<a class="click-info">Más Información</a>
<div class="img-dentro kenburns-top" style="background:url(<?php echo $imagen; ?>)no-repeat; background-size:cover;">
</div>
</div>
</div>
</div>
<?php else : ?>
<div class="vc_col-sm-6">
<div class="vc_row vc_row-fluid">
<div class="vc_col-sm-6 cont-der" >
<a class="click-info">Más Información</a>
<div class="img-dentro kenburns-top" style="background:url(<?php echo $imagen; ?>)no-repeat; background-size:cover;">
</div>
</div>
<div class="vc_col-sm-6 cont-izq">
<h3><?php the_title(); ?></h3>
</div>
</div>
</div>
<?php endif; endwhile; ?>
</div>
<?php endif; ?>
<?php wp_reset_query(); ?>
[EDIT]Try this:
<?php
$args = array(
'posts_per_page' => '-1',
'post_type' => 'inversion',
'category_name' => '',
'order' => 'DESC',
'orderby' => 'date',
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<div class="vc_row">
<?php
$float_class = '';
while ( $the_query->have_posts() ) :
$the_query->the_post();
if ( $the_query->current_post &&
$the_query->current_post % 2 === 0 ) {
$float_class = $float_class ? '' : 'vc_pull-right';
}
$imagen = get_the_post_thumbnail_url( get_the_ID(), 'full' );
?>
<div class="vc_col-sm-6">
<div class="vc_row vc_row-fluid">
<div class="vc_col-sm-6 cont-der <?php echo $float_class; ?>">
<a class="click-info">Más Información</a>
<div class="img-dentro kenburns-top" style="background:url('<?php echo esc_url( $imagen ); ?>') no-repeat; background-size:cover;">
</div>
</div>
<div class="vc_col-sm-6 cont-izq">
<h3><?php the_title(); ?></h3>
</div>
</div>
</div>
<?php endwhile; // end have_posts() loop ?>
</div><!-- .vc_row -->
<?php endif; // end have_posts() check ?>
<?php wp_reset_query(); ?>

How do you print an entire post into a page (wordpress)

Hi I've made a custom post type 'work_fields' that calls in information from yet another custom post type 'members' into the post, and now I'm trying to make a PAGE TEMPLATE that shows a list of the titles of custom post type 'work_fields', and when you click a title, the whole post('work_fields') will show up on a div called 'single-post-container' below the titles. right now I've got everything working fine, but I want to display a post in the div 'single-post-container' when the page loads. (as of now, just the titles of the posts are displayed and there is nothing in the div). How do I get the div to display the most recent post of custom post type 'work_fields' on page load? This is the code for the custom page template.
<div class="row">
<div class="small-12 medium-10 large-offset-1 columns">
<h2><?php the_title(); ?></h2>
</div>
</div>
<div class="row halfsection">
<div class="small-12 medium-10 large-offset-1 columns">
<div class="category_container">
<?php
$args = array('post_type' => 'work_fields',);
$query = new WP_Query( $args );
?>
<?php if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<p class="category_item"><a class="post-link" rel="<?php the_ID(); ?>" href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></p>
<?php endwhile; endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="small-12 medium-10 large-offset-1 columns">
<hr>
</div>
</div>
<div id="single-post-container">
//THIS IS WHERE THE POST CONTENTS SHOWS BUT I WANT THE MOST RECENT POST TO BE HERE ON PAGE LOAD, BEFORE I CLICK ANY OTHER POST//
</div>
Thank you! Your help is much appreciated!
Just use the WP_query twice by getting recent posts in the arguments,
$args2 = array('post_type' => 'work_fields', 'orderby' => 'ID', 'order'=> 'DESC' , 'posts_per_page' => 5);
$query2 = new WP_Query( $args2 );
?><div id="single-post-container"><?php
// The Loop
if ( $query2->have_posts() ) {
echo '<ul>';
while ( $query2->have_posts() ) {
$query2->the_post();
echo '<li>' . get_the_content() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
}
?></div><?php
Put the div outside loop. It will show the content of recent 5 posts.
If everything above the div single-post-container is working fine then for this specific div you can load most recent post by using code below. Be sure to reset previous post data using wp_reset_postdata()
Codex Documentation. https://codex.wordpress.org/Function_Reference/wp_get_recent_posts
<?php
$args = array(
'numberposts' => 1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'work_fields',
'post_status' => 'publish',
'suppress_filters' => true
);
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
?>
So I just recreated the post type markup on my page. I'm sure there's a better way to do this but for times sake I had to at least make it work. I also tried using a jquery onclick function and just click the first title after everything loads, but there was an error that just kept pushing all of the titles so I pretty much gave up.
here's the code
<div class="row">
<div class="small-12 medium-10 large-offset-1 columns">
<h2><?php the_title(); ?></h2>
</div>
</div>
<div class="row halfsection">
<div class="small-12 medium-10 large-offset-1 columns">
<div class="category_container">
<?php
$args = array(
'post_type' => 'work_fields',
);
$query = new WP_Query( $args );
?>
<?php if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<p class="category_item"><a class="post-link" rel="<?php the_ID(); ?>" href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></p>
<?php endwhile; endif; ?>
</div>
</div>
</div>
<div class="row">
<div class="small-12 medium-10 large-offset-1 columns">
<hr>
</div>
</div>
<div id="single-post-container">
<?php
$args2 = array(
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'work_fields',
'post_status' => 'publish',
'posts_per_page' => 1,
);
$query2 = new WP_Query( $args2 );
if ( $query2->have_posts() ) : ?>
<?php $post = get_post($_POST['id']); ?>
<div id="single-post post-<?php the_ID(); ?>">
<?php while ( $query2->have_posts() ) : $query2->the_post(); ?>
<div class="row section">
<div class="small-12 medium-7 large-offset-1 columns">
<h2><?php the_title(); ?></h2>
<h3>소개</h3>
<p class="halfsection"><?php the_field('work_fields_intro'); ?></p>
<h3>주요서비스</h3>
<p class="halfsection"><?php the_field('work_fields_service'); ?></p>
<h3>주요실적</h3>
<p class="halfsection"><?php the_field('work_fields_accomplishment'); ?></p>
</div>
<?php endwhile; endif; ?>
<div class="small-6 medium-3 large-2 columns large-offset-1 end">
<?php
$posts = get_field('team_member');
if( $posts ): ?>
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class="member_container halfsection">
<div class="member"><?php the_post_thumbnail(); ?></div>
<p class="member_name"><?php the_title(); ?></p>
<ul class="members_info">
<li><?php the_field('members_position'); ?></li>
<li><?php the_field('members_e-mail'); ?></li>
<li><?php the_field('members_phone'); ?></li>
</ul>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>

Use image as a Wordpress conditional

I'm trying to use a image as a conditional to show different post types. I have one post with images and another one without images. So I built a If else statement and a while loop that calls the post. At the end I have a page number code. But the loop is infinite, I'm not finding where to close it. Some one can help me?
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<div class="texto-longo">
<?php the_content(); ?>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
<div class="row-2 w-row">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 3,
'paged' => $paged,
'cat' => '3',
);
$wp_query = new WP_Query( $args );
?>
<?php if ( $wp_query->have_posts() ) : ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="_w-image container-novidades">
<?php if( get_field('imagem_do_evento') ): ?>
<div class="w-row">
<div class="column w-col w-col-4"><img class="<?php the_field('imagem_do_evento');?>">
</div>
<div class="colomn-text-novidades w-col w-col-8">
<h1 class="txt-blue"><?php the_title();?></h1>
<h3 class="txt-blue"><?php the_field('imagem_do_evento');?></h3>
<p><?php get_the_date('d/m/Y'); ?></p>
<p><?php the_field('imagem_do_evento');?></p>
</div>
</div>
</div>
<?php wp_reset_query(); else : ?>
<p>Ainda não temos novidades :(</p>
<?php endif; ?>
<?php endwhile; ?>
<?php if ($wp_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?>
<nav class="navegacao-paginas">
<div class="paginacao twisted w-inline-block">
<div class="seta-text"><?php echo get_previous_posts_link( '⟶' ); // display newer posts link ?></div>
</div>
<div class="paginacao w-inline-block">
<div class="seta-text"><?php echo get_next_posts_link( '⟶', $wp_query->max_num_pages ); // display older posts link ?></div>
</div>
</nav>
<?php } ?>
</div>
<?php wp_reset_query(); else : ?>
<?php endif; ?>
Try to put the endwhile and edn if in the same row like this
<?php endwhile; wp_reset_query(); endif; ?>
I Figured it Out. It was a div opening outside the if statement. And I wasn't closing all if else properly. Check out the final code.
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<div class="texto-longo">
<?php the_content(); ?>
</div>
<?php endwhile; wp_reset_query(); endif; ?>
<div class="row-2 w-row">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 3,
'paged' => $paged,
'cat' => '4',
);
$wp_query = new WP_Query( $args );
?>
<?php if ( $wp_query->have_posts() ) : ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php if( get_field('foto_novidades') ): ?>
<div class="_w-image container-novidades">
<div class="w-row">
<div class="column w-col w-col-4"><img class="img-novidades" src="<?php the_field('foto_novidades');?>">
</div>
<div class="colomn-text-novidades w-col w-col-8">
<h1 class="txt-blue"><?php the_title();?></h1>
<h3 class="txt-blue"><?php the_field('sub_titulo_novidades');?></h3>
<p><?php get_the_date('d/m/Y'); ?></p>
<p><?php the_field('texto_novidades');?></p>
</div>
</div>
</div>
<?php else:?>
<div class="container-novidades">
<h1 class="txt-blue"><?php the_title();?></h1>
<h3 class="txt-blue"><?php the_field('sub_titulo_novidades');?></h3>
<p><?php get_the_date('d/m/Y'); ?></p>
<p><?php the_field('texto_novidades');?></p>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php if ($wp_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?>
<nav class="navegacao-paginas">
<div class="paginacao twisted w-inline-block">
<div class="seta-text"><?php echo get_previous_posts_link( '⟶' ); // display newer posts link ?></div>
</div>
<div class="paginacao w-inline-block">
<div class="seta-text"><?php echo get_next_posts_link( '⟶', $wp_query->max_num_pages ); // display older posts link ?></div>
</div>
</nav>
<?php } ?>
</div>
<?php wp_reset_query(); else : ?>
<p>Ainda não temos novidades :(</p>
<?php endif; ?>

if have posts display div else display no posts statment

I have no idea why this code is not working. I am trying to create a conditional statement where if this custom post type has posts then display customer-section div. if post does not exist then print no post statement. I did everything I thought I am suppose to but I must be doing something silly wrong because I can still see the customer-section div even though there are no posts.
here is what I have:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="customer-section case-study">
<div class="case-study-container">
<h2>Case Studies</h2>
<?php $loop = new WP_Query( array( 'post_type' => 'case_study', 'posts_per_page' => 9 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ): ?>
<div class="press-featured-image">
<?php the_post_thumbnail('', array('class' => 'th')); ?>
</div>
<?php endif; ?>
<div class="blog-post">
<h3><?php the_title(); ?></h3>
<div class="entry-summery">
<?php the_excerpt(); ?>
</div>
<footer>
<?php $tag = get_the_tags(); if (!$tag) { } else { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
</div>
<hr />
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
What you are currently doing is checking if your initial have_posts() (the default query) condition is true and if this is a page template it is always true. Actually (for page templates) you don't need that check at all, since WordPress will return 404 if the page is not found.
You need a check for posts for your custom query:
<?php the_post(); ?>
<div class="customer-section case-study">
<div class="case-study-container">
<h2>Case Studies</h2>
<?php $loop = new WP_Query( array( 'post_type' => 'case_study', 'posts_per_page' => 9 ) );
if ( $loop->have_posts() ):
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ): ?>
<div class="press-featured-image">
<?php the_post_thumbnail('', array('class' => 'th')); ?>
</div>
<?php endif; ?>
<div class="blog-post">
<h3><?php the_title(); ?></h3>
<div class="entry-summery">
<?php the_excerpt(); ?>
</div>
<footer>
<?php $tag = get_the_tags(); if (!$tag) { } else { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
</div>
<hr />
</div>
<?php endwhile;
else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif;
wp_reset_query();
?>
</div>
</div>
I believe the issue is your syntax with the two loops.
You're missing the if statement before the while condition
You're trying to load your $loop loop inside the standard page or post loop.
Try this instead:
<?php
$case_studies = new WP_Query( array( 'post_type' => 'case_study', 'posts_per_page' => 9 ) );
if ( $case_studies->have_posts() ) : ?>
<div class="customer-section case-study">
<div class="case-study-container">
<h2>Case Studies</h2>
<?php while ( $case_studies->have_posts() ) : $case_studies->the_post(); ?>
<div <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ): ?>
<div class="press-featured-image">
<?php the_post_thumbnail('', array('class' => 'th')); ?>
</div>
<?php endif; ?>
<div class="blog-post">
<h3><?php the_title(); ?></h3>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div>
<footer>
<?php if (get_the_tags()) { ?>
<p><?php the_tags(); ?></p>
<?php } ?>
</footer>
</div>
<hr />
</div>
<?php endwhile; ?>
</div>
</div>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; wp_reset_query(); ?>
this is what worked for me. You don't need to end the while loop if it's inside the WP_Query. All you have to do is close the if statement for the main div you want to show, add the while for the repeating section and if it doesn't work, I'd try deleting the conditions you have set on your footer.
<?php $loop = new WP_Query( array( 'post_type' => 'case_study', 'posts_per_page' => 9 ) ); if($loop->have_posts()): ?>
<div class="customer-section case-study">
<div class="case-study-container">
<h2>Case Studies</h2>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ): ?>
<div class="press-featured-image">
<?php the_post_thumbnail('', array('class' => 'th')); ?>
</div>
<?php endif; ?>
<div class="blog-post">
<h3><?php the_title(); ?></h3>
<div class="entry-summery">
<?php the_excerpt(); ?>
</div>
<footer>
<?php $tag = get_the_tags(); if (!$tag) { } else { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
</div>
<hr />
</div>
<?php } wp_reset_postdata(); ?>
</div>
</div>
<?php endif; ?>

Categories