Book Worm…
BDW WordPress Class Canceled on Monday
BDW WordPress Class Canceled on Monday (29 April)…we will meet at the normal time next week (the 6th of May).
Hit me up with questions.
Something is growing on my office…
Now that’s a big chain ring…
Full story here.
WordPress Class
Hey BDW @ Night folks – it looks like CU has canceled classes for the evening – so let’s do the same.
We can talk next week and figure out if we want to re-schedule, do something via skype or google hangouts or extend the class a week.
Let me know if you have any questions.
See ya next week
Hank
WordPress Conditional Tags
The Conditional Tags can be used in your Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches.
http://codex.wordpress.org/Conditional_Tags
Common Conditional Tags
General
is_home()
When the main blog page is being displayed.
is_front_page()
When the front of the site is displayed, whether it is posts or a Page.
is_single()
When any single Post (or attachment, or custom Post Type) page is being displayed.
is_page()
When any Page is being displayed.
is_page( 42 )
When Page 42 (ID) is being displayed.
is_page( ‘About Me And Joe’ )
When the Page with a post_title of “About Me And Joe” is being displayed.
is_page( ‘about-me’ )
When the Page with a post_name (slug) of “about-me” is being displayed.
is_page( array( 42, 54, 6 ) )
Returns true when the Pages displayed is either post ID = 42, or post ID = 54, or post ID = 6.
is_page_template( ‘about.php’ )
Is Page Template ‘about’ being used?
Categories
is_category()
When any Category archive page is being displayed.
is_category( ’9′ )
When the archive page for Category 9 is being displayed.
is_category( ‘Stinky Cheeses’ )
When the archive page for the Category with Name “Stinky Cheeses” is being displayed.
is_category( ‘blue-cheese’ )
When the archive page for the Category with Category Slug “blue-cheese” is being displayed.
Custom Post Types
get_post_type()
Returns the registered post type of the current post.
Preview
is_preview()
When a single post being displayed is viewed in Draft mode.
Other Conditional Tags
- Tags
- Authors
- Taxonomies
- Archive
- Search
- 404
Examples
if ( is_page( 'about' ) || '2' == $post->post_parent ) { // the page is "About", or the parent of the page is "About" $bannerimg = 'about.jpg'; } elseif ( is_page( 'learning' ) || '56' == $post->post_parent ) { $bannerimg = 'teaching.jpg'; } elseif ( is_page( 'admissions' ) || '15' == $post->post_parent ) { $bannerimg = 'admissions.jpg'; } else { $bannerimg = 'home.jpg'; // just in case we are at an unclassified page, perhaps the home page } |
if ( is_single() ) { echo 'This is just one of many fabulous entries in the ' . single_cat_title() . ' category!'; } |
if ( is_home() || is_single() ) { the_content(); } else { the_excerpt(); } |
Custom Post Types & Templates to Display Them
Last week we worked with Custom Post types and discussed how they can be used to set up nearly any kind of data entry within WordPress – or examples were chickens…
We briefly looked at how these can be displayed on the front end of the site, but let’s dig in a bit deeper.
The Listing Page
This page functions much like the blog listing page for typical posts.
Here’s the code we can use to make it work. We will be using a custom page template to make this work.
$args = array( 'post_type' => 'chickens', 'order' => 'ASC', 'orderby' => 'title', 'posts_per_page' => -1 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); echo '<li><a href="' . get_permalink() . '">'; the_title(); echo '</a></li>'; endwhile; |
The Single Item Page
This template typically follows the format {custom-post-type-name}-single.php
<div class="small-12 large-8 columns" role="main"> <?php /* Start loop */ ?> <?php while (have_posts()) : the_post(); ?> <article <?php post_class() ?> id="post-<?php the_ID(); ?>"> <header> <h1 class="entry-title"><?php the_title(); ?></h1> </header> <div class="entry-content"> <?php the_content(); ?> <?php $meta_values = get_post_meta($post->ID); ?> <ul> <li><strong>Temperament:</strong> <?php echo $meta_values['ecpt_temperament'][0]; ?></li> <li><strong>Egg Yield:</strong> <?php echo $meta_values['ecpt_typicaleggyield'][0]; ?></li> <li><strong>Additional Notes:</strong> <?php echo $meta_values['ecpt_additionalnotes'][0]; ?></li> </ul> </div> <footer> <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'reverie'), 'after' => '</p></nav>' )); ?> <p><?php the_tags(); ?></p> </footer> </article> <?php endwhile; // End the loop ?> </div> <div class="large-4 columns"> <?php the_post_thumbnail('large'); ?> </div> |
$terms = get_terms("chicken_tags"); echo "<ul>"; foreach ( $terms as $term ) { echo "<li>" . $term->name . "</li>"; } echo "</ul>"; |




Recent Comments