Title: if Statement check validity, please
Last modified: August 18, 2016

---

# if Statement check validity, please

 *  [katgirl](https://wordpress.org/support/users/katgirl/)
 * (@katgirl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/)
 * Could someone PLEASE check and confirm if I’m doing this if statement right? 
   I seem to pull up an error, as in _“unexpected ‘,’ or ‘;’_ or something to that
   effect.
 * <have posts… while have posts… etc..>
    `<?php  if (is_page()) { //which one? 
   if (is_page('anthologies')) { echo "['hyperlink']Anthologies[/a]";  } elseif (
   is_page('contemporary')) { echo "['hyperlink']Contemporary[/a]"; }  ?> [div]carry
   on with template instructions[/div]
 * thanks heaps

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

 *  [designde](https://wordpress.org/support/users/designde/)
 * (@designde)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/#post-439006)
 * It looks like you are missing the final closing bracket see below:
 * `<?php
    if (is_page()) { //which one? if (is_page('anthologies')) { echo "['hyperlink']
   Anthologies[/a]"; } elseif (is_page('contemporary')) { echo "['hyperlink']Contemporary[/
   a]"; } } // Close initial if is_page ?>
 * I doubt you need the over-arching if is_page statement though, so you could just
   remove it:
 * `<?php
    if (is_page('anthologies')) { echo "['hyperlink']Anthologies[/a]"; } 
   elseif (is_page('contemporary')) { echo "['hyperlink']Contemporary[/a]"; }
 * ?>
 *  Thread Starter [katgirl](https://wordpress.org/support/users/katgirl/)
 * (@katgirl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/#post-439008)
 * edit: Sorry, designde – I was writing while you were too. I will implement your
   changes and report back. Maybe it will fix my footer 🙂 thanks heaps.
 * Okay – update.
 * I got the if statement to work (I damn near screamed my lungs out, I was so chuffed!)
 * I inserted `<php } ?>` directly after the closing ?> and shifted The Loop to 
   sit after that.
 * Now, the only problem I seem to have is that my footer is suddeny misaligned –
   instead of expanding 100% (fluid design) its now only expanding to fit the content
   section.
 * My theme is a 3 col liquid design.
 * Does anyone know what ? or > or * that I’v missed?
 *  Thread Starter [katgirl](https://wordpress.org/support/users/katgirl/)
 * (@katgirl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/#post-439014)
 * No go with the footer problem.
 * [@designde](https://wordpress.org/support/users/designde/), I removed the “over-
   arching” if statement and reduced the } by one and it renders beautifully!
 * Thank you so much. I’m no php programmer; it took me the better part of four 
   hours to come up with that if statement.
 * Just to clarify – it holds 11 if statements in that one code. 🙂
 * But my footer is shonkers.
 *  Thread Starter [katgirl](https://wordpress.org/support/users/katgirl/)
 * (@katgirl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/#post-439028)
 * Okay I fixed my footer problem. Just shifted the endif’s to sit outside my closing
   content div.
 * ==
 * For those who don’t really understand php and if statements, much like myself,
   this is what I did to generate a breadcrumb trail in my Pages and sub-pages. 
   It took me the better part of four hours to figure it out. While some may snigger
   and smirk, because it took me so long, I feel rather proud of myself for accomplishing
   what was, to me, extremely difficult. I know Zip about php, other than what I’ve
   learned here @ WordPress by using the template tags and studying templates and
   themes.
 * So in essence, four hours was nothing, right? Anyway, this is what I did.
 * I created one Page = Reviews
    I created sub page= Romance I created 11 sub-sub
   pages = various sub-genres
 * Reviews
    -Romance –anthologies –contemporary –etc…
 * I wanted a breakcrumb trail that would pick up the “category” name of my sub-
   sub pages, as well as the title of my Page.
 * Because I don’t know that much about php or if or is satements… I hand coded 
   the first part of my breadcrumb trail into my template to cover the inital bc
   link trail:
 * Home
    Reviews (main Page category) Romance (first sub-category)
 * Then I created a If Statement to find the category name of the first Sub-Sub-
   Page = Anthologies. I duplicated that if statement to also find, if applicable,
   the category name of any other Sub-Sub-Page category of Reviews/Romance (main
   parent/s) when viewing a page post.
 * I inserted the `<?php the_title(): ?>` tag at the end, so bascially my breadcrumb
   trail looks like this:
 * Home || Reviews || Romance || Anthologies || Dark Warrior (title of page/post)
 * The good thing about this, and the if statement, is that I made a Review template(
   main Page cat) and left it blank at this point (this will eventually display 
   current month reviews as link list). I also created Romance Template (first Sub
   Page Cat, which is also presently blank but will also eventually display top 
   10 links for each sub-genres as teasers) and finally, I made one generic template
   Sub-Genre for ALL sub-sub page posts.
 * And Voila.
 * One fully functional working “Category” breadcrumb trail. If anyone has a better
   way of doing this, I will be greatly interested.
 * K
 *  Thread Starter [katgirl](https://wordpress.org/support/users/katgirl/)
 * (@katgirl)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/#post-439148)
 * Just advising…
 * I’ve somehow ruined this – don’t know how, & I especially don’t know what, exactly,
   I ruined, but the **if statement** no longer displays the _name_ of my Page.
 * After fiddling with it for too many hours, I’m going to change strategies.
 * If someone has any advice as to how to effectively use the If statement inside
   a Page Template like such:
 * if (is_page('page-1')) {
    echo "[hyperlink/page-1]LINK[/a]"; elseif (is_page('
   page-2')) { echo "[hyperlink/page-2]LINK[/a]"; } ?>
 * Page categories:
    Page 1 -Page 2
 * I will be forever in your debt.

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

The topic ‘if Statement check validity, please’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [katgirl](https://wordpress.org/support/users/katgirl/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/if-statement-check-validity-please/#post-439148)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
