Articles for WP

Tweet 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.’; [...]

Tweet 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 [...]

Tweet 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 Facebook sharing is just getting more and more popular, and it is good to let your visitors share content on your blog using their Facebook profile. Facebook share button is easy to use – as copying this snippet and pasting it into your website. This way you can customize you Facebook share button by [...]

Tweet As I was surfing the net I have stumbled upon Jeffrey Way’s theme options page. Basic and simple option page that let’s you download the code in order to start making your own options page on your custom theme. If you are into WordPress – one day you will need it – so better [...]

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() [...]

Use WP 3.0 menu

In: PHP|WordPress

23 Aug 2010

Tweet WordPress 3.0 has added us a nice functionality for using custom menus. Allowing us to mix categories, pages and URLs, WP gives us option to make menus with ease. In order to implement WP 3.0 menu into you theme, just use following snippet: 1 2 3 4 5 wp_nav_menu( array( ‘menu’ => ‘Menu_name’, ‘container_class’ [...]

Make Magento Checkout Awesome