Title: if else code
Last modified: August 19, 2016

---

# if else code

 *  [Copywrite](https://wordpress.org/support/users/copywrite2012/)
 * (@copywrite2012)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/)
 * Hi all what is the correct syntax for this if else clause, I think I have the
   syntax slightly wrong. When the category is French I want it to show nothing 
   and when it is other categories I want it to show the string “Learn About”. Thank
   you
 *  `<h1 class=”pagetitle”>
    <?php } if (is_category(‘French’)) { ?> <?php } else{?
   > Learn about <?php printf(__(‘%s’, ‘kubrick’), single_cat_title(”, false)); ?
   ></h1> `

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [jrav001](https://wordpress.org/support/users/jrav001/)
 * (@jrav001)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760744)
 * Try removing the curley braces from this line:
    `<?php } if (is_category('French')){?
   >`
 *  Thread Starter [Copywrite](https://wordpress.org/support/users/copywrite2012/)
 * (@copywrite2012)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760804)
 * Thank you!
 *  Thread Starter [Copywrite](https://wordpress.org/support/users/copywrite2012/)
 * (@copywrite2012)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760857)
 * It doesn’t work 🙁
 *     ```
       <?php /* If this is a category archive */ if (is_category()) { ?>
       <h1 class="pagetitle">
       <?php if ( is_category('French class'))  ?>
       <?php } else { ?>
       Learn <?php printf(__('%s', 'kubrick'), single_cat_title('', false)); ?></h1>
       <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
       ```
   
 *  [jrav001](https://wordpress.org/support/users/jrav001/)
 * (@jrav001)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760858)
 * Sorry – I wasn’t clear…you need one of the curley braces so it should look like
   this:
    `<?php if ( is_category('French class')) { ?>`
 *  Thread Starter [Copywrite](https://wordpress.org/support/users/copywrite2012/)
 * (@copywrite2012)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760859)
 * Thanks for the reply, that doesn’t seem to work:
 *     ```
       <?php /* If this is a category archive */ if (is_category()) { ?>
       <h1 class="pagetitle">
       <?php if ( is_category('French Class')) { ?>
       <?php } else { ?>
       Learn <?php printf(__('%s', 'kubrick'), single_cat_title('', false)); ?></h1>
       <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
       ```
   
 *  Thread Starter [Copywrite](https://wordpress.org/support/users/copywrite2012/)
 * (@copywrite2012)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760865)
 * maybe I just need to get rid of the first bracket here?
    `<?php } else { ?>`
 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760867)
 * Indented your code to make it readable, and used : instead of {}
 *     ```
       <?php if (is_category()) : ?>
           <?php /* If this is a category archive */ ?>
       	<h1 class="pagetitle">
       		<?php if ( is_category('French')) : ?>
       		      <!-- Do Nothing Here -->
       		<?php else : ?>
       			Learn <?php printf(__('%s', 'kubrick'), single_cat_title('', false)); ?>
       		<?php endif; ?>
       	</h1>
       <?php elseif (is_tag()) : ?>
         <?php /* If this is a tag archive */ ?>
             <!-- Do stuff Here -->
       <?php endif; ?>
       ```
   
 * There is no output for category ‘French’ so you could just use ! which is the
   operator ‘not’
 *     ```
       <?php if (is_category()) : ?>
           <?php /* If this is a category archive */ ?>
       	<h1 class="pagetitle">
       		<?php if ( !is_category('French')) : ?>
       			Learn <?php printf(__('%s', 'kubrick'), single_cat_title('', false)); ?>
       		<?php endif; ?>
       	</h1>
       <?php elseif (is_tag()) : ?>
         <?php /* If this is a tag archive */ ?>
             <!-- Do stuff Here -->
       <?php endif; ?>
       ```
   
 * HTH
 * David

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘if else code’ is closed to new replies.

 * 7 replies
 * 3 participants
 * Last reply from: [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/if-else-code/#post-1760867)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
