WordPress Goodies

A few tidbits for WordPress I picked up this week working on Psychic Coupons and a couple other sites.


This is an oldie but goody, helps a lot: http://codex.wordpress.org/Template_Hierarchy
and the PNG: http://codex.wordpress.org/images/1/18/Template_Hierarchy.png


Here’s one from equalmark and banago at http://wordpress.org/support/topic/query-if-on-front-page-home-index :
If you’re on the front page, conditional statements:

<?php if(is_front_page() ) { ?> //do stuff <?php } ?>
— or --
<?php if(is_home() ) { //do stuff } else { //do stuff } ?>

Mvied notes: I’d just like to point out that the is_home() function is true if you’re on the main blog page, and the is_front_page() function can be the same page unless you have a static front page set, then it will only be true on that page.


Passing variables in the URL, by stvwlf from http://wordpress.org/support/topic/passing-variables-using-the-permalink-structure :

Step 1:
Create and save PHP file in plugins directory:
/* Plugin Name: Parameter
Plugin URI: http://webopius.com/
Description: A plugin to allow parameters to be passed in the URL and recognized by WordPress
Author: Adam Boyse
Version: 1.0
Author URI: http://www.webopius.com/
add_filter('query_vars', 'parameter_queryvars' );

function parameter_queryvars( $qvars )
$qvars[] = ' myvar';
return $qvars;
Step 2:
Pass var in URL href:
if (isset($wp_query->query_vars['myvar']))
print $wp_query->query_vars['myvar'];


Find and show related posts by tag: http://wordpress.org/support/topic/variables-through-get_posts-query_posts


elseloop offers a simple way to implement a “Post template based on category”: http://wordpress.org/support/topic/post-template-based-on-category-or-tag


I just want to pass my thanks to the many talented people who take the time to share their expertise on the WordPress community forum. They are adding value to the world, so, KUDOS to all you geniuses!

Posted under WebDev, WordPress

This post was written by Content Curator on April 10, 2012

Tags: , , , , , , , , , , , , , , , , ,