In: WordPress
7 Oct 2010Tweet In order to convert category ID to category name in WordPress, you can use get_cat_name(). This is a WordPress function that will help you get category name based on category ID. It can be used when you know category name might be changed, and you know ID will stay the same. See snippet below [...]
Tweet When making customization for our WordPress theme, often we need to check if user is logged in. It is a simple task when using a WordPress function is_user_logged_in(). Here is a simple snippet that shows you how to check if user is logged in or not. 1 2 if(is_user_logged_in()) echo ‘You are logged in.’; [...]
In: WordPress
18 Sep 2010Tweet If you would like to present number of posts on your WordPress blog – than you could use WP function called wp_count_posts(). And if you want to just count published posts, follow the snippet below: echo ‘So far – we have published: ‘ . wp_count_posts()->publish . ‘ posts!’; Example of count posts Stunt snippets [...]
In: WordPress
17 Sep 2010Tweet Sometimes, there is a need to replace WordPress admin logo in wp-admin of your clients website. It is a simple task – simple to do as copying this snippet into your functions.php file, and adding your clients logo to folder images in your WordPress theme. 1 2 3 4 5 6 7 8 9 [...]
In: WordPress
15 Sep 2010Tweet WordPress shortcodes are powerful but rarely used functions. It is simple to use WordPress shortcodes by calling WordPress function add_shortcode. You can use it to show your sharing buttons, RSS feeds, Google AdSense or just your signature. To make this simple function works with you – just copy following snippet into your themes functions.php [...]
Tweet Sometimes there is a need to get posts outside of WordPress. In order to get latest couple of posts and present them as news outside of WP, I have written a function that might be useful. This function has two parameters. First one is database connection, and second is optional array of parameters used [...]
Tweet Recently, on website wprecipes.com, I have stumbled upon an interesting script displaying how to integrate your Google Analytics code into your WordPress theme by modifying only functions.php. To do so, just copy and paste following snippet into your functions.php in your current WordPress theme. 1 2 3 4 5 add_action(’wp_header’, ‘ga’); function ga() [...]