How to easily wish a merry Christmas to your blog readers

To achieve this very simple recipe, simply paste the following code anywhere on your theme. The "Merry Christmas" message will be displayed only on Christmas day.

Merry Christmas from WPRecipes!

By the way, merry Christmas to all of you! Have a great time with the family.


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.


WordPress hack: Remove autolinks in comments

To remove automatic linking of urls in comments, simply open your functions.php file and paste the following: remove_filter('comment_text', 'make_clickable', 9);

That's all! Once saved, you can say bye bye to spammy links in comments.

This recipe has been initially published on CatsWhoCode. Don't forget to read CWC's list of 10 new WordPress hacks!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

WordPress tip: How to make term edition easier

Simply paste this function on your functions.php file:

if ( !function_exists('edit_term_link') ) { function edit_term_link( $link = '', $before = '', $after = '', $term = null ) { if ( $term == null ) { global $wp_query; $term = $wp_query->get_queried_object(); } $tax = get_taxonomy( $term->taxonomy ); if ( !current_user_can($tax->cap->edit_terms) ) return; if ( empty($link) ) $link = __('Edit This'); $link = '' . $link . ''; echo $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; }}

Once you saved your functions.php file, add the following code on any category, tag or taxonomy template:

It will output a link (only if you're logged in as an administrator, of course) to quickly edit the term.

Thanks to Joost de Valk for this great function!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to count your blogroll links

Simply paste the following code where you want the count to be displayed:

get_var("SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = 'Y'");if (0 < $numlinks) $numlinks = number_format($numlinks);echo $numlinks;?>

Thanks to Jeff Starr for this tip!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to show a different number of posts for a WordPress category

I used this tip on a category that's very image intensive to show only 5 posts rather than 10 posts per page. This allowed me to reduce page load times on this category page, whilst still leaving the rest of the website easy to browse.

Open up archive.php and add the following code before the loop.

And then after the loop, just paste this:

You can use any of the conditional tags to determine when to show more or less pages, I chose to use the function that checks for a category by name. I hope it comes in useful!

Thanks to Dan Harrison of WP Doctors for the tip!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to easily get post ancestors

In order to get the post ancestors (also called parents) simply use the get_post_ancestors() function. This function takes a single argument which can be either the post ID or post object, and return the ancestors IDs as an array. $ancestors = get_post_ancestors($post);

Thanks to Coen Jacobs for this great piece of code!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to use WordPress shortcode outside in your theme files

Simply use the do_shortcode() function anywhere in your theme file. The shortcode you want to use have to be given to the function as shown below:

That's all :)

Recipe initially published on CatsWhoCode.


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to count retweets in full text on your WordPress posts

The first thing to do is to open your functions.php file and insert the following function:

function tweetCount($url) { $content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url); $element = new SimpleXmlElement($content); $retweets = $element->story->url_count; if($retweets){ return $retweets; } else { return 0; }}

Once done, open your single.php file and paste the following:

$rt = tweetCount(get_permalink());echo "Retweeted ".$rt." times.";

Source


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to set HTML editor as the default in WordPress

Simply paste the following code on your functions.php file, save it, and you're done!

add_filter('wp_default_editor', create_function('', 'return "html";'));

Credit: WP Snippets.


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

How to easily modify user contact info

Simply paste the following function into your theme functions.php file. Lines 2, 3 and 4 are for removing unnecesseray items, and lines 5, 6 and 7 add news items. That's simple as that.

function extra_contact_info($contactmethods) { unset($contactmethods['aim']); unset($contactmethods['yim']); unset($contactmethods['jabber']); $contactmethods['facebook'] = 'Facebook'; $contactmethods['twitter'] = 'Twitter'; $contactmethods['linkedin'] = 'LinkedIn'; return $contactmethods;}add_filter('user_contactmethods', 'extra_contact_info');

Advanced users would probably enjoy this class which allow you to manage user contact info easily.

Big thanks Thomas Griffin for the snippet!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.

WordPress trick: Get category slug using category ID

First, put the following function in your functions.php file:

function get_cat_slug($cat_id) {$cat_id = (int) $cat_id;$category = &get_category($cat_id);return $category->slug;}

Once done, you can call the function as shown below:

This will display the slug for the category with the ID 3.

Thanks to Ken Rosaka for the tip!


View the original article here


This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.


How to set a maximum word count on post titles

If you ever wanted to be able to set a maximum word count of post titles so your contributors will not define titles that are too long, the following recipe is for you. I’ll show you how you can easily set a maximum word count on post titles.

To apply this hack, simply paste the following in your functions.php file:

function maxWord($title)

View the Original article

WordPress hack: Remove autolinks in comments

By default, WordPress automatically turns urls left in the comment form into links. This can be useful, but as there’s lots of spammers on the internet, you might want to remove this feature.

To remove automatic linking of urls in comments, simply open your functions.php file and paste the following:remove_filter('comment_text', 'make_clickable', 9);

That's all! Once saved, you can say bye bye to spammy links in comments.

This recipe has been initially published on CatsWhoCode. Don't forget to read CWC's list of 10 new WordPress hacks!

If you enjoyed this article, please consider sharing it!

View the Original article

How to use WordPress shortcode outside in your theme files

WordPress shortcode are extremely useful, but many people thinks you can’t use them outside of the editor, for example in your theme files. But you can, and it’s pretty easy. Just read this recipe to know how to do.

Simply use the do_shortcode() function anywhere in your theme file. The shortcode you want to use have to be given to the function as shown below:


View the Original article

How to show a different number of posts for a WordPress category

WordPress allows you to vary how many blog posts you show on your blog, but it’s a single setting, and affects how many blog posts show over the whole website. This tip allows you to have a different number of posts for a particular category.

I used this tip on a category that's very image intensive to show only 5 posts rather than 10 posts per page. This allowed me to reduce page load times on this category page, whilst still leaving the rest of the website easy to browse.

Open up archive.php and add the following code before the loop.


View the Original article

How to easily get post ancestors

When using WordPress as a CMS or building a breadcrumb, you often need to get the post ancestors. Today let’s have a look at how you can easily get post ancestors of a specific post.

In order to get the post ancestors (also called parents) simply use the get_post_ancestors() function. This function takes a single argument which can be either the post ID or post object, and return the ancestors IDs as an array.$ancestors

View the Original article

How to easily modify user contact info

The default user profile allows users to display their msn, aim, jabber and yahoo messenger adresses. But in 2010, you might want to add more recents services such as Twitter or Facebook. Here’s a recipe to do so.

Simply paste the following function into your theme functions.php file. Lines 2, 3 and 4 are for removing unnecesseray items, and lines 5, 6 and 7 add news items. That's simple as that.

function extra_contact_info($contactmethods)

View the Original article

How to count retweets in full text on your WordPress posts

Twitter and other third parties sites have great widgets that allow you to display how many times your posts have been retweeted. But how to do it in full text, without using a widget? Just read this recipe and you’ll know how you can easily do it.

The first thing to do is to open your functions.php file and insert the following function:

function tweetCount($url)

View the Original article

WordPress tip: How to make term edition easier

WordPress have lots of useful built-in function, unfortunely there’s no function to allow the quick edition of a term (category, tag, or custom term). Nevermind, we can still built our own.

Simply paste this function on your functions.php file:

if ( !function_exists('edit_term_link') )

View the Original article

How to count your blogroll links

Did you ever want to display how many blogroll links you have in total? If yes, just read this recipe. It’s pretty easy to do using the $wpdb object and some SQL.

Simply paste the following code where you want the count to be displayed:


View the Original article

How to set HTML editor as the default in WordPress

In WordPress dashboard, the default editor is the “Visual Editor”. It is probably the editor that most people enjoy, but personally I prefer using the HTML editor. If you’re like me you’ll probably like this tip which will make the HTML editor as the default.

Simply paste the following code on your functions.php file, save it, and you're done!

add_filter('wp_default_editor', create_function('', 'return "html";'));

Credit: WP Snippets.

If you enjoyed this article, please consider sharing it!

View the Original article