Many people don’t like to load the master jQuery library from a CDN (Content Delivery Network), if something happens to the CDN the jQuery library will not load. This would cause some, if not all, of your website features to no longer work.
Use the following snippet to load jQuery from a local file, into your WordPress footer, if it fails when loading from your CDN of choice.
function inline_footer_scripts(){ ?><!-- LOCAL JQUERY FALLBACK -->
<script type="text/javascript">window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.1.7.1.min.js"><\/script>');</script>
<?php }
add_action('wp_footer', 'inline_footer_scripts', 1);
Ever want to display your post time stamp similar to the way Facebook or Twitter does? WordPress has this ability built-in! Just paste the following snippet wherever you would like to display the time for your post.
echo human_time_diff(get_the_time('U'), current_time('timestamp')) .' '. __('ago', 'theme_name');
It’s official, WordPress 3.3 named “Sonny” has been officially released on December 13, 2011. There have been numerous changes made to enhance user experience and easier publishing.
Easier Uploading
- File Type Detection
- Drag-and-Drop Media Uploader
- More File Formats
Dashboard Design
- Flyout Menus
- Header + Admin Bar = Toolbar
- Responsive Design
- Help Tabs
New Features
- New Feature Pointers
- Post-update Changelog
- Dashboard Welcome
Most people will tell you that in order to have a pretty search URL in WordPress you either use a plugin, or insert some code into your .htaccess file. This is simply not true. Just add this snippet code into your functions file and you can have pretty WordPress search URLs.
function search_url_rewrite(){
if(is_search() && !empty($_GET['s'])){
wp_redirect(home_url("/search/"). urlencode(get_query_var('s')));
exit();
}
}
add_action('template_redirect', 'search_url_rewrite');
This snippet works for WordPress 2.2+.