Code

Get custom field outside the WordPress loop

Do you want to get a custom field outside the WordPress loop (e.g. in your sidebar) and you have no idea how? The following code snippet will help you do it. * Replace the ‘customField’ in the 4th line with the name of your custom field. <?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, ‘customField’, […]

read more

Creating a Simple Shortcode

WordPress shortcodes are actually very easy to create. If you know how to write a basic PHP function, then you already know how to create a WordPress shortcode. For our first shortcode, let’s create the well-known “Hello, World” message. Open the functions.php file in your theme. If it doesn’t exist, create one. First, we have […]

read more

WordPress “Send to Twitter” Button Without Using a Plugin

There are lots of plugins that let you insert a Send to Twitter button into your posts. If you don’t want to use one or if you want to have the Send to Twitter button only in specific posts then you can make a shortcode that you will use only wherever you want it to […]

read more

Include jQuery in your WordPress Theme

If you want to include jQuery in your WordPress Theme the best way to do it is the following. Add this code to the theme’s functions.php file: if( !is_admin()){ wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”), false, ‘1.4.1’); wp_enqueue_script(‘jquery’);} Replace the URL with the location of what version of jQuery you want to use. The URL above (at the […]

read more

Display Recently Updated Posts/Pages

In order to display the recently updated posts/pages in your WordPress blog…

read more

Display Recent Posts

Display recent posts of your WordPress blog / website without using a plugin. Simply copy and paste the following …

read more

What Are Shortcodes?

Introduced in WordPress 2.5, shortcodes are powerful but still yet quite unknown WordPress functions. Imagine you could…

read more