Title: syntax problems in If statement using in_category
Last modified: August 21, 2016

---

# syntax problems in If statement using in_category

 *  [lberelson](https://wordpress.org/support/users/lberelson/)
 * (@lberelson)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/if-statement-using-in_category/)
 * Having some trouble with a loop. Currently starting a bunch of loop conditionals
   for the loop file. This is the first and only loop so far and I’m having syntax
   issues. The basic loop works fine. Please help.
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post() ; ?>
       <?php if  (in_category ('programs')) {
       	<h1 class="section">echo 'Classes'; </h1>
       }
        else  {
       	<h1 class="section">  echo get_the_title( $post->post_parent ); </h1>
       }
        endif;
       	<a href="<?php the_permalink(); ?>"><h1 style="font-weight:bold"><?php the_title(); ?></h1>  </a>
       ?>
       <?php the_content(); ?>
       <?php endwhile; endif; ?>
       ```
   

The topic ‘syntax problems in If statement using in_category’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [if statement](https://wordpress.org/support/topic-tag/if-statement/)
 * [in category](https://wordpress.org/support/topic-tag/in-category/)
 * [in_category](https://wordpress.org/support/topic-tag/in_category/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 0 replies
 * 1 participant
 * Last reply from: [lberelson](https://wordpress.org/support/users/lberelson/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/if-statement-using-in_category/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
