WordPress

WordPress Tags for Development

WordPress Tags for Development
While doing wordpress development here in Dallas, Tx. I find that I need a tag reference quite often. I lifted this from another site, but it should do the trick. If any other graphic designers, or web developers run across this, I hope it helps.

<?php if ( is_page(‘about’)) { echo ‘<div id=”secondnav”>This is the super cool secondary navigation.</div>’; } ?>view raw example1.php This Gist brought to you by GitHub. The code is asking if the page is named “about”, if it is, it echo’s the div “secondnav”. If the page isn’t called “about” then it echo’s nothing and nothing is displayed. It’s that simple. If you want the nav to display on the “about”and “contact”page add this

<?php if ( is_page(‘about’) || is_page(‘contact’)) { echo ‘<div id=”secondnav”>This is the super cool secondary navigation.</div>’; } ?>view raw example2.php This Gist brought to you by GitHub. One place I find myself using this a lot is loading javascript only on pages that need it. One problem of adding javascript links to your footer.php file is that they are called on everypage whether you need them or not. The simple way to call them only when need is to add them like this

<?php if ( is_page(‘about’)) { echo ‘<script type=”text/javascript” src=”http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js”></script>’; } ?>view raw example3.php This Gist brought to you by GitHub. This works well for pages, but for your blog page and single posts you will need a different function.

For your blog page use is_home()

For your single posts use is_single()

WordPress provides a slew of other tags as well including

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(), is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(), is_page_template(), is plugin active(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(), is_taxonomy(), is_taxonomy_hierarchical(), is_term(), is_user_logged_in(), is_blog_installed(), is_active_sidebar(), is_dynamic_sidebar(), is_active_widget()

Contact Form 7 – Thank You Pages

on_sent_ok: "location.replace('http://www.website.co.uk/thank-you/');"

Pages-AddNew

A Great Overall Guide to Pages in WordPress

Taken from the WordPress.org Codex – http://codex.wordpress.org/Pages