Quantcast
Channel: WPRecipes
Browsing all 121 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Automatically spam comments with a very long url

Open your functions.php file and paste the code below in it. This code will automatically mark as spam all comments with an url longer than 50 chars. This can be changed on line 4. <?php function...

View Article


Image may be NSFW.
Clik here to view.

How to add nofollow attributes to all links in a specific category

Simply copy the code below and paste it on your functions.php file. Don't forget to set the desired category ID on line 3. function nofollow_cat_posts($text) { global $post; if( in_category(1) ) { //...

View Article


Image may be NSFW.
Clik here to view.

How to automatically insert a list of related articles below the post

First, paste the code below into the functions.php file from your theme. // "More from This Category" list by Barış Ünver @ Wptuts+ function wptuts_more_from_cat( $title = "More From This Category:" )...

View Article

Image may be NSFW.
Clik here to view.

Themes4all giveaway: LOTS of prizes to win!!

A word about Themes4All Our sponsor is Themes4All.com, which is a newcomer in the WordPress premium theme business. They specialize in low cost/high quality themes. They already released 20+ themes,...

View Article

Image may be NSFW.
Clik here to view.

Automatically link Twitter usernames in WordPress

Paste the code below into your functions.php file: function twtreplace($content) { $twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\"...

View Article


Image may be NSFW.
Clik here to view.

How to use WordPress shortcodes in theme files

To use a shortcode in a theme file, simply use the do_shortcode() function as shown below: <?php echo do_shortcode("[your_shortcode]"); ?> That's it. Super simple, and really useful at times!

View Article

Image may be NSFW.
Clik here to view.

How to setup different admin and theme languages on your WordPress blog

Simply set the desired locale (on line 6) then add the code to your functions.php file. <?php // setup one language for admin and the other for theme // must be called before load_theme_textdomain()...

View Article

Image may be NSFW.
Clik here to view.

WordPress shortcode to embed Google trends graphs

The first step is to create the shortcode. To do so, open your functions.php file and paste the code below in it: function wps_trend($atts){ extract( shortcode_atts( array( 'w' => '500', // width...

View Article


Image may be NSFW.
Clik here to view.

How to crop uploaded images instead of scaling them

Just add the code below to your functions.php file: // Standard Size Thumbnail if(false === get_option("thumbnail_crop")) { add_option("thumbnail_crop", "1"); } else { update_option("thumbnail_crop",...

View Article


Image may be NSFW.
Clik here to view.

WordPress tip: Force specific pages to be SSL secure

Just add the following snippet to the functions.php file of your WordPress theme and specify the post or page ID desired. function wps_force_ssl( $force_ssl, $post_id = 0, $url = '' ) { if ( $post_id...

View Article

Image may be NSFW.
Clik here to view.

WordPress tip: Check whether a plugin is active

Just paste the code below in your theme file, wherever you'd like to check out if a plugin is activated or not. Update the code with the plugin directory and name on line 4. <?php include_once(...

View Article

Image may be NSFW.
Clik here to view.

WordPress tip: check if a post has a gallery

Simply paste the function below into your functions.php file: function hasgallery(){ global $post; return (strpos($post->post_content,'[gallery') !== false); } Once done, you can use it to detect if...

View Article

Image may be NSFW.
Clik here to view.

WordPress SEO: Automatically remove short words from the URL

Paste the code below into your functions.php file. Once you saved the file, WordPress will automatically remove short (less than 3 characters) words from the generated permalink....

View Article


Image may be NSFW.
Clik here to view.

WordPress function to check if the current post is a custom post type

Simply paste this code into your functions.php file: function is_custom_post_type() { global $wp_query; $post_types = get_post_types(array('public' => true,'_builtin' => false),'names','and');...

View Article

Image may be NSFW.
Clik here to view.

WordPress tip: Conditional tag for blog-related pages

Copy the function below and paste it into your functions.php file: function is_blog() { if (is_home() || is_singular('post') || is_post_type_archive('post')) return true; else return false; } Once...

View Article


Image may be NSFW.
Clik here to view.

WordPress tip: View all WP query variables

Paste the code below on any files, where you'd like to display the WP Query variables. global $wp_query; var_dump($wp_query->query_vars); Thanks to WP Mix for the tip!

View Article

Image may be NSFW.
Clik here to view.

Giveaway: 3 premium themes from ThemeFuse

A word about ThemeFuse ThemeFuse is one of the most popular actors in the premium WordPress themes market. They provide lots of themes with a great design and solid code. They have lots of different...

View Article


Image may be NSFW.
Clik here to view.

WordPress tip: Email alert for 404s

To implement, simply include this script at the top of your theme’s 404.php file. If your theme don’t have a 404.php file, then create it. <?php // WP 404 ALERTS @...

View Article

Image may be NSFW.
Clik here to view.

How to load jQuery from Google CDN

Paste the code below into your functions.php file: function jquery_cdn() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery',...

View Article

Image may be NSFW.
Clik here to view.

How to automatically add Gravatars for the post author

Simply paste the following code where you’d like the author Gravatar to be displayed. Please note that this code must be used within the loop. <?php echo get_avatar( get_the_author_email(), '80' );...

View Article
Browsing all 121 articles
Browse latest View live