Conditional Tags

Wordpress Conditional tags examples
language: PHP
license: Other

Code for Snippet:

                
//is_page
 
<?php  if ( is_page('First_Page') ) { ?><br>  
<img src="image.gif" /><br>  
<?php  } elseif ( is_page('Third_Page') ) { ?><br>  
<p>Here is some text….</p><br>  
<?php  } else { ?><br>  
<?php  } ?>
 
//is_category
 
<?php  if(is_category(Category_Page) ) || ( is_single(Single_Page))  { ?>  
<p>Display  this text….</p>  
<?php  } else { ?>  
<?php  } ?>
 
//Conditional Scripts if page
<?php  if ( is_page( 'contact_us_page' ) ) {   ?>  
<link  rel='stylesheet' href='/contactusform.css' type='text/css' media='all' />  
<script  type='text/javascript' src=k'/jqueryform.js'></script>  
<script  type='text/javascript' src='/spec_forms.js'></script>  
<?php  } ?>
 
//Conditional Custom Post Types
<?php  if ( review_entry' == get_post_type() ) { ?> 
<div  id="reviewcontact"> 
<p>If  you're impressed by the  reviews, kindly  contact us asap. Give us a call or <a href="/contact"  title="Contact Us">CLICK HERE</a> to send us a message!</p>  
</div>  
<?php  } ?>
 
 
comments powered by Disqus

Info

Tags: Wordpress

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 960
Date Added: 2013-03-08 15:44:38
Last Modified: 2013-03-15 10:23:00

Web Analytics