Title: HTML inside PHP
Last modified: August 21, 2016

---

# HTML inside PHP

 *  Resolved [dprogramb](https://wordpress.org/support/users/dprogramb/)
 * (@dprogramb)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/html-inside-php/)
 * I have the following line of code in a page template and I want to make it conditional
   on the post category. The problem I’m facing is nested PHP.
 *     ```
       <p><?php the_time(__("F j, Y", 'organicthemes')); ?> &middot; <a href="<?php the_permalink(); ?>#respond"><?php comments_number(__("Leave a Comment", 'organicthemes'), __("1 Comment", 'organicthemes'), __("% Comments", 'organicthemes')); ?></a> <?php edit_post_link(__("(Edit)", 'organicthemes'), '', ''); ?></p>
       ```
   
 * I do something like this, and it doesn’t work…for obvious reasons.
 *     ```
       <?php if (!in_category(array('bishop-column','bishops-blog')))
       				<p><?php the_time(__("F j, Y", 'organicthemes')); ?> &middot; <a href="the_permalink(); #respond> comments_number(__("Leave a Comment", 'organicthemes'), __("1 Comment", 'organicthemes'), __("% Comments", 'organicthemes'));
       				?></p>
       ```
   
 * My problem is I don’t know how to approach it.

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

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/html-inside-php/#post-3837267)
 * The basics for using `if()` statements like that is that it’s always easier (
   and a lot safer) to include the ending part as well. I know that it’s possible
   to leave it off, but it’s a very eays way to run into big issues if somethings
   not 100% right.
 * You’d need to use something like this…
 *     ```
       <?php if (!in_category(array('bishop-column','bishops-blog'))): ?>
       	<p>Your code in here...</p>
       <?php endif; ?>
       ```
   
 * One word of advice too – check the quotes that you’re using because you’ll break
   the JavaScript call if you use ” ‘s inside other ” ‘s without proper escaping.
   If it was me, I’d set up an external JavaScript file and use that to handle the
   JS side of things.
 *  Thread Starter [dprogramb](https://wordpress.org/support/users/dprogramb/)
 * (@dprogramb)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/html-inside-php/#post-3837326)
 * Thanks so much, catacaustic! Works like a charm.
 *  Thread Starter [dprogramb](https://wordpress.org/support/users/dprogramb/)
 * (@dprogramb)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/html-inside-php/#post-3837327)
 * Thanks also for the tip on the endif and the quotes!
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/html-inside-php/#post-3837328)
 * That’s all good. It always takes time to learn new things like this, so any help
   that you can get along the way is always a bonus.

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

The topic ‘HTML inside PHP’ is closed to new replies.

## Tags

 * [conditional statement](https://wordpress.org/support/topic-tag/conditional-statement/)
 * [html](https://wordpress.org/support/topic-tag/html/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/html-inside-php/#post-3837328)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
