<div class='breadcrumb'><h1><?php
// if there is a parent, display the link
if ( $post->post_parent ) {
$parent_title = get_the_title($post->post_parent);
if ( $parent_title != the_title(' ', ' ', false) ) {
echo '<a href=' . get_permalink($post->post_parent)
. ' ' . 'title=' . $parent_title . '>' . $parent_title
. '</a> » ';
}
}
?>
<?php the_title(); ?>
</h1></div>
The difference is in the details. Here's an easy script to add your site's logo to the WP login screen. This will look for a logo.png file in your theme's images directory but you can change that to whatever you'd like. The script automatically use the site name you entered in WP as the img title and will use your site's url as the link. You will probably need to adjust the css to fit your logo or image dimensions accordingly. Enjoy…
// changing the WP logo to something a bit sexier…
add_action("login_head", "my_login_head");
function my_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('stylesheet_directory')."/images/logo.png') no-repeat scroll center top transparent;
display: block;
height: 80px;
left: 50%;
margin: 0 0 0 -56px;
width: 440px;
}
body.login #login h1 {
display: block;
margin: 0 auto;
}
body.login #login {
margin: 2em auto 7em;
width: 320px;
}
</style>
";
}
// changing the title attr on the login logo
add_filter('login_headertitle', create_function(false,"return '".get_bloginfo( 'name' )."';"));
add_filter('login_headerurl', create_function(false,"return '".get_bloginfo( 'siteurl' )."';"));
Often times it's necessary to have very granular control on sub navigation for pages. This little snippet solves that issue. It adds a metabox to WordPress pages that allows users to select from an automatically generated list of menus that have been created through the default WP Menus functionality.
Add this to your functions.php file
$prefix = '_dbt_';
$meta_boxes = array();
// Custom sub menu select
function makeMyMenus() {
$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
global $menuArray;
$menuArray = array('select a sub menu');
foreach ( $menus as $menu ) {
$menuArray[] = $menu->name;
}
}
makeMyMenus();
// Adding sub menu drop down to pages.
$meta_boxes[] = array(
'id' => 'sub_menu',
'title' => 'Sub Menu',
'pages' => array('page'), // applicable post types
'context' => 'side',
'priority' => 'low',
'fields' => array(
array(
'name' => 'Sub Menu',
'desc' => 'The sub menu for this page created via Appearance > Menus',
'id' => $prefix . 'custom_menu',
'type' => 'select',
'options' => $menuArray
)
)
);
Front end use. Place this in your theme files where you want the menu to appear
ID, '_dbt_custom_menu', true) == true ) {
$menuName = get_post_meta($post->ID, '_dbt_custom_menu', true);
wp_nav_menu( array('menu' => $menuName, 'fallback_cb' => false ));
} // end if has link ?>
I had the hardest time (harder than it should have been anyway) trying to figure out how to filter my posts using WP_Query and the value of a checkbox (checked or not). As it turns out the value is "on". See an example below of that and how to use multiple custom meta values to filter your content.
$args = array(
'post_type' => 'athletes',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'dbt_gender',
'value' => 'male'
),
array(
'key' => 'dbt_basketball',
'value' => 'on'
)
)
);
$the_query = new WP_Query( $args );
while ($the_query->have_posts()) : $the_query->the_post();
// DO YOUR LOOP MESS HERE!!!
endwhile;
(Updated 5/11)
Every now and then a WordPress plugin is close but not quite what you need. In the (usually not recommended) event that you have to hack a plugin's logic, you'll probably want to disable the update feature for that plugin so no one can upgrade and overwrite your changes. I take no credit for writing this code as it is taken completely from htmlgraphic.com. (I like to keep archives just in case)
// prevent update notifications to avoid overwriting customizations
add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_prevent_update_check( $r, $url ) {
if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) {
$my_plugin = plugin_basename( __FILE__ );
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[$my_plugin] );
unset( $plugins->active[array_search( $my_plugin, $plugins->active )] );
$r['body']['plugins'] = serialize( $plugins );
}
return $r;
}
If you're plugins are already showing update notifications add this to /wp-includes/update.php, refresh the plugins page and remove this afterward.
get_site_transient( 'update_plugins' ); // unset the plugin
set_site_transient( 'update_plugins', " ); // reset plugin database information
If you've hacked the WordPress core you may want to check out this plugin to disable updating of WP itself.
I was recently working on a project and the background was not showing up in IE7 (or IE6 but who cares about that browser?!?!). After much frustration, simply declaring the height on the element did the trick. (height: 100%; in this case). This appears to have also resolved an issue where the image-based backgrounds on some elements were sporadically disappearing when the page was scrolled (in IE7 of course). Part of the background would disappear when it went out of view when scrolling. Chalk up a few more hours on my bill to Microsoft's IE dev team.
I searched for hours to find a solution for this and finally stumbled upon this plugin. Custom Post Type Permalinks. This is a great plugin that allows you to add .html to custom post types in wordpress. You can actually create any permalink structure similar to the way permalinks are handled in WordPress by default.
It can be somewhat annoying that WP automatically inserts <p> tags into your posts and pages via the WYSIWYG editor. In order to 86 this functionality you can just add remove_filter ('the_content', 'wpautop'); to your functions.php file. You'll now have to add paragraph tags manually but if you're semi-savvy with basic html, that shouldn't be an issue.
I found all sorts of complicated posts on the in-ter-net about this but none were clear and concise. Hopefully this will be… (but I'm no Flash expert) I basically needed to pass an xml file path to a Flash image rotator through the embed/object markup in the html file. Using FlashVars this is actually pretty easy in AS3. note: I usually use swfobject to work with Flash but this particular project called for the more "traditional" embed/object tags.
The html markup…
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="348" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="FlashVars" value="xml_path=xml/news2.xml" /><param name="src" value="preview.swf" /><param name="flashvars" value="xml_path=xml/news2.xml" /><embed type="application/x-shockwave-flash" width="640" height="348" src="preview.swf" flashvars="xml_path=xml/news2.xml" wmode="transparent" quality="high"></embed></object>
The ActionScript code…
root.loaderInfo.parameters.xml_path;
(or if you need it in a variable…)
var xmlFilePath:String = root.loaderInfo.parameters.xml_path;
Hope that helps someone.
Had the oddest thing happen today; The spacebar and option keys stopped working while I was using Illustrator CS4. I did a little searching and testing and found that Firefox (v3.6) was the culprit. I quit FF and the spacebar/hand tool/option keys were back! I was able to restart Firefox and everything is still working fine with both programs running. I'm sure other programs could cause this issue as well. Odd bug that can drive you crazy. Makes you realize how important that little spacebar is.
This gets placed in your theme's functions.php… 'Signup' is the text for the register link in this example. 'Logout' is the message displayed when the user is logged in. That could easily be a link to their profile or the admin area as well.
add_action( 'register' , 'register_replacement' );
function register_replacement( $link ){
if ( ! is_user_logged_in() ) {
if ( get_option('users_can_register') )
$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Signup') . '</a>' . $after;
else
$link = ";
} else {
$link = $before . '<a href="' . wp_logout_url() . '">' . __('Logout') . '</a>' . $after;
}
return $link;
}
login-lockdown – protect your neck
nextgen gallery – great for internally managed photo galleries
tubepress – let youtube handle the bandwidth and conversion please.
eventsmanager (for RSVP type events)
gigpress (for musician-style tours)
capabilities manager – if you have multiple content editors with varying roles.
Mail From – change the default from email address and name.
exclude-pages – sometimes the main nav doesn't need to be that cluttered
user photo – great for adding some personality especially with multiple content authors
maintenance mode – show users something professional while testing and updating
shadowbox js / lightbox PLUS – sexy photo/video presentation
advanced twitter widget – meh. it works well for client managed twitter feeds.
Register Plus – get all the info you can from your users
all in one SEO pack – what good is a site if no one finds it
kadom-ads-management – if you have savvy enough admins to manage their own ad space
wp super cache – great for high-traffic sites but can cause issues with some plugins
formbuilder – submits forms via email and to the db. export to csv. nice.
FeedBurner FeedSmith – if you're into feedburner for rss feed management. This plugin works excellently.
With the release of WordPress 2.9, there have been a couple nice little enhancements to excerpts. It's now very easy to change the good old [...] to whatever you'd like including a simple "More" link that links to the post. It's also now just as easy to control the length of the excerpts as well. Simply use the code below as a starting point. Place this code in your theme's functions.php
function new_excerpt_more($more) {
return '… <a href="'.get_permalink().'">MORE</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
function new_excerpt_length($length) {
return 30;
}
add_filter('excerpt_length', 'new_excerpt_length');
I love WordPress and I use it pretty much exclusively for small to mid-sized website development. WordPress development is quick, easy and website owners love the fact that there's none of the complications that come with proprietary content management systems. Sometimes it becomes necessary to move your beloved WordPress sites to other servers or directories. I've found many online resources elaborating on this topic including the WordPress docs themselves. I prefer to have a quick reference guide for my own purposes though. I've given credit and links where applicable.
If you're moving a WordPress site to a different server or a different directory on the current server there are several steps to go through to ensure that everything works correctly on the other side of the move.
The Database Edits: (from My Digital Life)
SQL From phpMyAdmin or similar: (in phpMyAdmin go to the top level of the database by clicking on the db name and click on the "SQL" tab. don't forget to add the appropriate db table prefix if different from the default wp_ )
UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
On occasion you may need to add this to your config.php file: (from the WordPress Codex)
define('WP_HOME','http://www.new-site-location.com');
define('WP_SITEURL','http://www.new-site-location.com/subdirectory-if-applicable');
Sometimes it's necessary to update permalinks by simply going to SETTINGS > PERMALINKS and clicking on SAVE CHANGES. you don't have to change anything, just click the button. Not sure why but it works.
The WordPress Codex has a detailed article on moving WordPress available.
Don't forget to check your theme files (and Flash!) for hard-coded file paths.