Wordpress - If is string


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php $category = get_the_category();?>
  2.  
  3. <?php if($category[0]->cat_name == 'Title1'): ?>
  4. <h2>Title 1</h2>
  5. <?php else : ?>
  6. <h2>Title 2</h2>
  7. <?php endif ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.