Display WordPress Categories without Children

November 22, 2008

If you are displaying your categories somewhere and would like to remove the children, here is the code you’ll need (for WordPress 2.5+): The depth=1 is the important one for the purpose of this hack as it is what tells WordPress not to display more than your parent categories.   By default, it is of course set to depth=0 (shows all categories).   If you are wondering what other options you have, here is what the WordPress Codex lists for the depth parameter: 0 - All Categories and child Categories (Default). -1... [Read the full story]

Prevent wordpress admin to be tracked by Google analytics

November 22, 2008

How can we’ll be able to prevent the blog admin from being tracked as a normal visitor by Google Analytics or any other tracking code. We need the current_user_can() WordPress function. This function checks the given parameter, which is the level of the current user, and returns true if the level of the current user is superior or equals to the given parameter. The following code will track any visitor or blog contributor exept the admin, if he’s logged in, of course. <?php if (!current_user_can('level_10')){ ?> INSERT... [Read the full story]

Use the WordPress 2.7 way to list your pages

November 21, 2008

Wordpress 2.7 will contain a bunch of new functions, as for exemple the wp_page_menu() function. Here’s how to use this new function to create stunning page menus. Prior to WordPress 2.7, we had to use the wp_list_pages() function to get an unordered list of our pages. The main problem was probably that this function can’t handle a link back to your homepage. We had to ad this link manually. This is done without any manual editing with the new wp_page_menu() function: Just add the show_home=Home parameter. Also, another... [Read the full story]

Create a wordpress 2.7 compatible comments template

November 20, 2008

WordPress 2.7 includes a lot of new enhancements, but one of the big ones is the new comment functionality. Comments can be threaded, paged, etc. This is all built in, but unfortunately, your theme must support it. So, for theme authors, I’d suggest getting to work on making your themes compatible right away. How to create a wordpress 2.7 compatible comments.php If you want your theme to be backward compatible as well, then there’s a simple way to do it. Just check for the wp_list_comments function, like so: if (function_exists('wp_list_comments'))... [Read the full story]

List all wordpress posts on a page

November 20, 2008

How we can create a table of content for his WordPress blog? Here’s a simple code which can also be used to create an archive page. To achieve this recipe, you first need to create a page template. First, on this page template, paste the following code; Then, login to your WordPress dashboard, write a new page and select this page as a template. <?php /* Template Name: All posts */ ?> <?php $debut = 0; //The first article to be displayed ?> <?php while(have_posts()) : the_post(); ?> <h2><?php... [Read the full story]

Page 4 of 10« First...«23456»...Last »