Title: Need some help with code
Last modified: August 20, 2016

---

# Need some help with code

 *  Resolved [mcbethar](https://wordpress.org/support/users/mcbethar/)
 * (@mcbethar)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/need-some-help-with-code/)
 * Hi to all,
 * I’m needing some help with this piece of code:
 * `<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>`
 * It tells to use a H1 tag (on the tittle) in front page and/ or home.
    I need 
   to edit this same code, adding that it must use a H2 tag if posts.
 * Thanks in advanced for your time, and sorry for my poor english.
    Sincerely,
 * Mcbethar

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/need-some-help-with-code/#post-2868707)
 * this should use a h2 on single post pages:
 * `<?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : (( is_single())?'
   h2' : 'div'); ?>`
 * or you can write it conventional:
 *     ```
       <?php if( is_home() || is_front_page() ) : $heading_tag = 'h1';
       elseif( is_single() ) : $heading_tag = 'h2';
       else : $heading_tag = 'div';
       endif; ?>
       ```
   
 *  Thread Starter [mcbethar](https://wordpress.org/support/users/mcbethar/)
 * (@mcbethar)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/need-some-help-with-code/#post-2868739)
 * Hey alchymyth,
 * Thanks a lot for your fast and accurated response!
 * It looks great. Either way I decided to just “clean” the code, in order to show
   H1 on title in all the pages, so that permalink keeps H2:
 * `<?php $heading_tag = 'h1'; ?>`
 * Lot of thanks again for your time 🙂
 * Sincerely,
 * Mcbethar

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

The topic ‘Need some help with code’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [H1](https://wordpress.org/support/topic-tag/h1/)

 * 2 replies
 * 2 participants
 * Last reply from: [mcbethar](https://wordpress.org/support/users/mcbethar/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/need-some-help-with-code/#post-2868739)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
