Favorite Codex Tip Of The Day

To remove meta boxes created by plugins, ‘admin_menu’ is fired too early, use ‘do_meta_boxes’ instead. Such a simple thing, but I wasted at least 15 minutes by using the wrong action hook. The meta box in this case was not created by a plugin, but by the parent theme of a child theme that I …

Read more »

Set Line Height in Komodo

Have I mentioned that I love Komodo IDE? Still, I occasionally come across an annoyance. One very annoying thing is that there is no way to change the line height in the editor other than changing the font size. I like to have a larger than average line height for better readability. I recently noticed …

Read more »

Change Admin Post/Page List Color By Status

Favorite WordPress tip of the week: This snippet will change the background colors of posts, pages, and custom post types in the administration post/page lists based on their status, i.e. draft, private, pending, etc. <?php add_action('admin_footer','posts_status_color'); function posts_status_color(){ ?> <style> .status-draft { background: #ffffe0 !important ; } .status-future { background: #cf9 !important; } .status-publish { …

Read more »

Don’t get_the_permalink()

get_the_permalink() does not exist. Use get_permalink(). Note to self: Debug my own site like I would debug any other site. I have used that function an uncountable amount of times, but got confused anyway because of having get_the_title() on my brain. This tip was brought to you by the half hour of my life that …

Read more »

Get the Current Page URL

I am working on a site now where I need to use the current page URL as a condition to determine where the main menu links will lead. This function has made an easy task of it: // Get current page URL function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} …

Read more »

Komodo Snippet for Comment Banners

I like to keep my code organized and easy to read, but since I am almost always working on a tight deadline, I do not always have time to organize and comment my code as well as I would like to. Shortcuts that aid in keeping my code organized are more likely to get used …

Read more »

Customize the WordPress Login Page

I love WordPress and am personally very happy to see the WordPress logo when I log into a site, but when building sites for some clients (and on my own development site where I build sites for clients to preview), it is nice to use their own logo for the login page. It gives a …

Read more »

Display Custom Fields In & Out of The Loop

INSIDE THE LOOP: <?php if ( get_post_meta($post->ID, 'custom-field-name', true) ) : echo get_post_meta($post->ID, 'custom-field-name', true); endif; ?> OUTSIDE THE LOOP: <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'custom-field-name', true); wp_reset_query(); ?>

Numbered Search Results in WordPress

I needed to show search results in an ordered list for a project I am working on and was very surprised to discover how involved this is for paginated search results. Showing the results using a regular ordered list starts the list numbering over at 1 on each new page of results, even though the …

Read more »

Function: wp_tag_cloud

Usage: <?php wp_tag_cloud( $args ); ?> Defaults: <?php $args = array( 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'separator' => \"\n\", 'orderby' => 'name', 'order' => 'ASC', 'exclude' => null, 'include' => null, 'topic_count_text_callback' => default_topic_count_text, 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true ); ?> …

Read more »

Genesis: Remove/Change post info/post meta

// Remove post meta remove_action('genesis_after_post_content', 'genesis_post_meta'); // Customize the post meta function add_filter('genesis_post_meta', 'post_meta_filter'); function post_meta_filter($post_meta) { if (!is_page()) { // Spaces are added to [ shortcodes ] for display. Do not include. $post_meta = 'Filed Under: [ post_categories ], Tagged: [ post_tags ]'; return $post_meta; }} // Remove the post info function remove_action('genesis_before_post_content', 'genesis_post_info'); …

Read more »

Genesis: Custom loop arguments

remove_action('genesis_loop', 'genesis_do_loop'); add_action('genesis_loop', 'custom_do_cat_loop'); function custom_do_cat_loop() { global $query_args; // any wp_query() args $args= array('orderby' => 'title', 'order' => 'ASC'); genesis_custom_loop(wp_parse_args($query_args, $args)); }

Genesis: Custom Page Template

<?php // Template Name: Template Name Here remove_action('genesis_loop', 'genesis_do_loop'); add_action('genesis_loop', 'custom_loop'); function custom_loop() { global $paged; $args = array('post_type' => 'PostType'); // any wp_query args can go here genesis_custom_loop( $args ); } genesis();

Genesis: Default Post Thumbnail

// Default post thumbnail add_filter('genesis_get_image', 'default_image_fallback', 10, 2); function default_image_fallback($output, $args) { global $post; if( $output || $args['size'] == 'full' ) return $output; $thumbnail = CHILD_URL.'/images/thumb.jpg'; switch($args['format']) { case 'html' : return '<img src="'.$thumbnail.'" class="alignleft post-image" alt="'. get_the_title($post->ID) .'" />'; break; case 'url' : return $thumbnail; break; default : return $output; break; } }

Genesis Grid Loop

New in Genesis 1.5 CSS: /* Featured Post Grid ———————————————————— */ .genesis-grid-even { float: right; padding: 0 0 15px; width: 48%; } .genesis-grid-odd { clear: both; float: left; padding: 0 0 15px ; width: 48%; } .genesis-grid-even, .genesis-grid-odd { margin: 0 0 20px; } PHP: /* functions.php: ———————————————————— */ add_image_size('grid-thumbnail', 100, 100, TRUE); /* home.php: …

Read more »

Change Login Page Logo

<?php /** * Change the logo on the login page. Make the image no wider than 320px and no taller than 82px. */ function custom_login_logo() { ?> h1 a { background: url(/custom/images/logo_login.png) 50% 50% no-repeat !important; } <?php } add_action('login_head', 'custom_login_logo'); /** * Change where the logo on the login page links to */ function …

Read more »

CSS Column Classes and Shortcodes

CSS: /* * Uses column classes from GaryJ's variation of Brian Gardner's Genesis column classes * http://www.studiopress.com/support/showthread.php?t=50959 */ .one-half, .one-third, .two-thirds, .one-fourth, .two-fourths, .three-fourths, .one-fifth, .two-fifths, .three-fifths, .four-fifths, .one-sixth, .two-sixths, .three-sixths, .four-sixths, .five-sixths { float: left; margin: 0 0 20px; padding-left: 3%; } .one-half, .two-fourths, .three-sixths { width: 48%; } .one-third, .two-sixths { width: 31%; …

Read more »

Genesis: Custom search button and search form text

// Search form text add_filter('genesis_search_text', 'custom_search_text'); function custom_search_text($text) { return esc_attr('Search…'); } // Add custom text for search button add_filter('genesis_search_button_text', 'custom_search_button_text'); function custom_search_button_text($text) { return esc_attr('Go'); }

Genesis Footer Content

Customize the footer text add_filter('genesis_footer_creds_text', 'custom_footer_creds_text'); function custom_footer_creds_text($creds) { $creds = '&copy;' . date('Y') . ' ' . get_bloginfo('name') . '. All rights reserved. Powered by <a href="http://wordpress.org/">WordPress</a>.'; echo $creds; } Remove Footer Content This will remove the footer credits text and ‘back to top’ link. add_filter('genesis_footer_output', 'footer_output_filter', 10, 1); function footer_output_filter($footer_content) { $footer_content = …

Read more »

Genesis: Custom superfish arguments

// functions.php function custom_superfish_menu() { if ( genesis_get_option('nav_superfish') ) { wp_deregister_script('superfish-args'); wp_enqueue_script('superfish-args', CHILD_URL.'/superfish.args.js', array('jquery'), '1.0', TRUE); } } add_action('get_header', 'custom_superfish_menu'); // superfish.args.js jQuery(document).ready(function($) { $('#nav ul.superfish, #subnav ul.superfish, #header ul.nav, #header ul.menu').superfish({ delay: 0, // delay on mouseout speed: 'fast', animation: {opacity:'show',height:'show'}, // fade-in and slide-down animation autoArrows: false, dropShadows: false, // disable drop shadows …

Read more »