WordPress Search With Relevanssi plugin

Wordpress search

The search functionality that’s built in to WordPress isn’t good. More specifically the inability to search between all categories, tags, or even a specific category and/or tag.

Similarly all posts are displayed on default by date, newest to oldest. This is a huge gap in UX, what about users who may be looking for popular articles with the most views or comments?

Reference
http://www.hongkiat.com/blog/wordpress-search-plugin-snippet/

Search Unleashed is a popular search plugin, but it hasn’t been updated since 2010. Relevanssi is in active development and does what Search Unleashed does

With WordPress Search

  • WordPress search results are listed chronologically. It sorts the results by date, newest first(not by relevance)
  • Further the search result can not be filter or sort.
  • Search only deal with post title and content( Not in tags, categories and custom fields)

In search result page
Search doesn’t support Filtering.

Search Unleashed is a popular search plugin, but it hasn’t been updated since 2010.

Relevanssi is in active development and does what Search Unleashed does.

With Relevanssi plugin

  • Search results sorted in the order of relevance, not by date.
  • Log queries, show most popular queries and recent queries
  • Search terms highlighted.
  • Search tags, categories and custom fields, custom post types and custom taxonomies.
  • Google-style “Did you mean?” suggestions based on successful user searches
  • Advanced filtering by taxonomy,date and sort by Relevance, Latest, Most Popular
  • Use stop words to make search better

http://www.relevanssi.com/features

Known issue:
Once content updated, we need to build the index( indexing are manual not automated)
How Relevanssi works
Additional 4 tables are not a issue.

Sarch terms and content are indexed (like sphinx, but the terms are stored in a database
table). So search query only deals with one table.

“Did you mean?” suggestion only work, if we enable your logs in settings page
‘Successful user searches’ logs are the Suggestions. For correct suggestion we need lot of
‘successful user searches’

Most Rated post by category, tags and archives in wordpress

Using WP-PostRating plugin we can display most rated post by category, tags and archives. It’s more useful to know the best one of that particular category, tags and archives. I am using this concept in my project (higginbothamsstore.com) to display most rated books by category vice.

Code:

<div id=”sidebar”>

<?php if(is_category() || is_single()){?>

<h3 id=”widgettitle”>Most Rated books in <?php single_cat_title(); ?> </h3>

<div id=”mainright” style=”width:99%;”>

<?php if (function_exists(‘get_most_rated_category’)): ?>

<?php $cat_ID = get_query_var(‘cat’);?>

<ul>

<?php get_most_rated_category($cat_ID,’post’,0,5); ?>

</ul>

<?php endif; ?>

</div>

<?php }?>

</div>

WP-PostRatings 1.50 For WordPress 2.8.x

preview

More Instructions

General Usage
  1. Open wp-content/themes/<YOUR THEME NAME>/index.phpYou may place it in archive.php, single.php, post.php or page.php also.
  2. Find:

    <?php while (have_posts()) : the_post(); ?>

  3. Add Anywhere Below It (The Place You Want The Ratings To Show):

    <?php if(function_exists(‘the_ratings’)) { the_ratings(); } ?>

    If you DO NOT want the ratings to appear in every post/page, DO NOT use the code above. Just type in [ratings] into the selected post/page content and it will embed ratings into that post/page only.

    If you want to embed other post ratings, use [ratings id=”1″], where 1 is the ID of the post/page ratings that you want to display.

    If you want to embed other post ratings results, use [ratings id=”1″ results=”true”], where 1 is the ID of the post/page ratings results that you want to display.

Displaying Comment Author Ratings
  1. Open wp-content/plugins/wp-postratings/wp-postratings.php
  2. Find:

    //add_filter(‘comment_text’, ‘comment_author_ratings_filter’);

  3. Replace:

    add_filter(‘comment_text’, ‘comment_author_ratings_filter’);

Note
  • To use PNG images instead of GIF images:
    1. Open wp-content/plugins/wp-postratings/wp-postratings.php
    2. Find:

      define(‘RATINGS_IMG_EXT’, ‘gif’);
      //define(‘RATINGS_IMG_EXT’, ‘png’);

    3. Replace:

      //define(‘RATINGS_IMG_EXT’, ‘gif’);
      define(‘RATINGS_IMG_EXT’, ‘png’);

  • WP-PostRatings will load ‘postratings-css.css‘ from your theme’s directory if it exists.
    • If it doesn’t exists, it will just load the default ‘postratings-css.css’ that comes with WP-PostRatings.
    • This will allow you to upgrade WP-PostRatings without worrying about overwriting your ratings styles that you have created.
Ratings Stats (With Widgets)
  1. Go to ‘WP-Admin -> Appearance -> Widgets
  2. The widget name is Ratings.
Ratings Stats (Outside WP Loop)
  • To Display Lowest Rated Post
  • Use:

    <?php if (function_exists(‘get_lowest_rated’)): ?>
    <ul>
    <?php get_lowest_rated(); ?>
    </ul>
    <?php endif; ?>

    Default: get_lowest_rated(‘both’, 0, 10)

    The value ‘both’ will display both the lowest rated posts and pages.

    If you want to display the lowest rated posts only, replace ‘both’ with ‘post’.

    If you want to display the lowest rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 lowest rated posts/pages.

  • To Display Lowest Rated Post By Tag
  • Use:

    <?php if (function_exists(‘get_lowest_rated_tag’)): ?>
    <ul>
    <?php get_lowest_rated_tag(TAG_ID); ?>
    </ul>
    <?php endif; ?>

    Default: get_lowest_rated_tag(TAG_ID, ‘both’, 0, 10)

    Replace TAG_ID will your tag ID. If you want it to span several categories, replace TAG_ID with array(1, 2) where 1 and 2 are your categories ID.

    The value ‘both’ will display both the lowest rated posts and pages.

    If you want to display the lowest rated posts only, replace ‘both’ with ‘post’.

    If you want to display the lowest rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 lowest rated posts/pages.

  • To Display Lowest Rated Post In A Category
  • Use:

    <?php if (function_exists(‘get_lowest_rated_category’)): ?>
    <ul>
    <?php get_lowest_rated_category(CATEGORY_ID); ?>
    </ul>
    <?php endif; ?>

    Default: get_lowest_rated_category(CATEGORY_ID, ‘both’, 0, 10)

    Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.

    The value ‘both’ will display both the lowest rated posts and pages.

    If you want to display the lowest rated posts only, replace ‘both’ with ‘post’.

    If you want to display the lowest rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 lowest rated posts/pages.

  • To Display Highest Rated Post
  • Use:

    <?php if (function_exists(‘get_highest_rated’)): ?>
    <ul>
    <?php get_highest_rated(); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_rated(‘both’, 0, 10)

    The value ‘both’ will display both the highest rated posts and pages.

    If you want to display the highest rated posts only, replace ‘both’ with ‘post’.

    If you want to display the highest rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 highest rated posts/pages.

  • To Display Highest Rated Post By Tag
  • Use:

    <?php if (function_exists(‘get_highest_rated_tag’)): ?>
    <ul>
    <?php get_highest_rated_tag(TAG_ID); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_rated_tag(TAG_ID, ‘both’, 0, 10)

    Replace TAG_ID will your tag ID. If you want it to span several categories, replace TAG_ID with array(1, 2) where 1 and 2 are your categories ID.

    The value ‘both’ will display both the highest rated posts and pages.

    If you want to display the highest rated posts only, replace ‘both’ with ‘post’.

    If you want to display the highest rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 highest rated posts/pages.

  • To Display Highest Rated Post In A Category
  • Use:

    <?php if (function_exists(‘get_highest_rated_category’)): ?>
    <ul>
    <?php get_highest_rated_category(CATEGORY_ID); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_rated_category(CATEGORY_ID, ‘both’, 0, 10)

    Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.

    The value ‘both’ will display both the highest rated posts and pages.

    If you want to display the highest rated posts only, replace ‘both’ with ‘post’.

    If you want to display the highest rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 highest rated posts/pages.

  • To Display Highest Rated Post Within A Given Period
  • Use:

    <?php if (function_exists(‘get_highest_rated_range’)): ?>
    <ul>
    <?php get_highest_rated_range(‘1 day’); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_rated_range(‘1 day’, ‘both’, 10)

    The value ‘1 day’ will be the range that you want. You can use ‘2 days’, ‘1 month’, etc.

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Display Most Rated Post
  • Use:

    <?php if (function_exists(‘get_most_rated’)): ?>
    <ul>
    <?php get_most_rated(); ?>
    </ul>
    <?php endif; ?>

    Default: get_most_rated(‘both’, 0, 10)

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Display Most Rated Post In A Category
  • Use:

    <?php if (function_exists(‘get_most_rated_category’)): ?>
    <ul>
    <?php get_most_rated_category(CATEGORY_ID); ?>
    </ul>
    <?php endif; ?>

    Default: get_most_rated_category(CATEGORY_ID, ‘both’, 0, 10)

    Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Display Most Rated Post Within A Given Period
  • Use:

    <?php if (function_exists(‘get_most_rated_range’)): ?>
    <ul>
    <?php get_most_rated_range(‘1 day’); ?>
    </ul>
    <?php endif; ?>

    Default: get_most_rated_range(‘1 day’, ‘both’, 10)

    The value ‘1 day’ will be the range that you want. You can use ‘2 days’, ‘1 month’, etc.

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Display Highest Score Post
  • Use:

    <?php if (function_exists(‘get_highest_score’)): ?>
    <ul>
    <?php get_highest_score(); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_score(‘both’, 0, 10)

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Display Highest Score Post In A Category
  • Use:

    <?php if (function_exists(‘get_highest_score_category’)): ?>
    <ul>
    <?php get_highest_score_category(CATEGORY_ID); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_score_category(CATEGORY_ID, ‘both’, 0, 10)

    Replace CATEGORY_ID will your category ID. If you want it to span several categories, replace CATEGORY_ID with array(1, 2) where 1 and 2 are your categories ID.

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 0 refers to the minimum votes required before the post get shown.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Display Highest Score Post Within A Given Period
  • Use:

    <?php if (function_exists(‘get_highest_score_range’)): ?>
    <ul>
    <?php get_highest_score_range(‘1 day’); ?>
    </ul>
    <?php endif; ?>

    Default: get_highest_score_range(‘1 day’, ‘both’, 10)

    The value ‘1 day’ will be the range that you want. You can use ‘2 days’, ‘1 month’, etc.

    The value ‘both’ will display both the most rated posts and pages.

    If you want to display the most rated posts only, replace ‘both’ with ‘post’.

    If you want to display the most rated pages only, replace ‘both’ with ‘page’.

    The value 10 will display only the top 10 most rated posts/pages.

  • To Sort Highest/Lowest Rated Posts
  • You can use:

    <?php query_posts($query_string.’&r_sortby=highest_rated&r_orderby=desc’) ?>

    Or pass in the variables to the URL:

    http://yoursite.com/?r_sortby=highest_rated&r_orderby=desc

    You can replace desc with asc if you want the lowest rated posts.

  • To Sort Most/Least Rated Posts
  • You can use:

    <?php query_posts($query_string.’&r_sortby=most_rated&r_orderby=desc’) ?>

    Or pass in the variables to the URL:

    http://yoursite.com/?r_sortby=most_rated&r_orderby=desc

    You can replace desc with asc if you want the least rated posts.

Advanced PHP code for wordpress

Content Only For The Home Page
<?php if ( is_home() ) { include (‘example.php’); } ?>
This snippet will include the file specified, only if the user is on the home page of the site. Place this code in the index.php file.
Styling Different Categories
<?php if ( is_category(’15’) ) {
<link rel=”stylesheet” href=”<?php bloginfo(‘template_url’); ?>/cat-15.css”
type=”text/css” media=”screen” />;
<?php } else { ?>
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>”
type=”text/css” media=”screen” />
<?php } ?>
This snippet assigns a specific stylesheet (category-15.css) to category 15 and will assign the rest of the site the default stylesheet (style.css). Place this code in the <head> area.
Unique Images For Different Categories
<?php if (is_category(‘7’) ):
<img src='<?php bloginfo(‘template_url’); ?>/images/cat7.jpg’ alt=” />
<?php } elseif (is_category(‘8’) ):
<img src='<?php bloginfo(‘template_url’); ?>/images/cat8.jpg’ alt=” />
<?php endif; ?>
This snippet assigns an image (cat7.jpg) next to each post title in category 7 and an image (cat8.jpg) next to each post title in category 8. Place this code in the category.php file.
Styling Individual Posts
<div id=”post-<?php the_ID(); ?>”>
This snippet will assign the post ID to the DIV. For example, if the ID for the post is 8, that line will echo as
<div id=”post-8”></div>. Now you can style that individual post in the CSS as #post-8. Place this code
within the loop.
Previous & Next Posts Links
<?php next_posts_link(‘Next Entries &raquo;’) ?>
<?php previous_post_link(‘&laquo; Older Entries’); ?>
The first snippet will echo “Next Entries »” with a link to the next set of posts. The second snippet will echo “« Previous Entries” with a link to the previous set of posts. Place this code outside the loop.
Site Page Links
<ul>
<li<?php if(is_home()) { ?> class=”current_page_item”<?php } ?>><a href=”
<?php bloginfo(‘home’); ?>”>home</a></li>
<?php wp_list_pages(‘sort_column=menu_order&depth=1&title_li=’); ?>
</ul>
This snippet will first echo the text “home” with a link to the home page. Next, it will echo the WordPress pages links in a list, in order defined by your settings, excluding the child pages, and excluding a title header for the list. If one of the pages in the list is active, the link for that page will be assigned the class “current_page_item”, which can now be styled in your CSS. Place this code in the template files.
Dynamic Page Titles
<?php
if (is_home()) { echo bloginfo(‘name’); } elseif (is_404()) { echo ‘ 404’; } elseif
(is_search()) { echo ‘ Search Results’; } else { echo ‘WPCandy » ‘; wp_title(”); }
?>
If the home page is active, the title will display the name of the site. If the 404 page is active, the title will echo ‘ 404’. If the Search Results page is active, the title will echo ‘ Search Results’. If any other page on the site is active, the title will display ‘WPCandy » [page name]’. Place this code in the <head> area.
Query Posts
<?php query_posts(‘cat=2&showposts=5’); ?>
This snippet will display the 5 latest posts from only category 2. Place this code right before the loop.
Unique Templates For Categories
<?php $post = $wp_query- >post;
if ( in_category(‘3’) ) {
include(TEMPLATEPATH . ‘/cat3.php’);
} elseif ( in_category(‘4’) ) {
include(TEMPLATEPATH . ‘/cat4.php’);
} else {
include(TEMPLATEPATH . ‘/cat.php’);
}?>
This snippet will assign a unique template to certain categories. In this case, ‘cat3.php’ will be assigned to ‘Category 3’, ‘cat4.php’ will be assigned to Category 4’, and the rest of the categories will be assigned ‘cat.php’. Place this code at the top of category.php.
Tag Cloud
<?php wp_tag_cloud(‘smallest=1&largest=9&’); ?>
This snippet will create a tag cloud, in alphabetical order, with the smallest text at 1 pt and the largest text at 9 pts.

PHP Code for WordPress

Grab Category Name

This PHP snippet will get the category of the current post and place it in line where the code is inserted. It would be useful to add a heading or phrase that relates to the category.

<? $cat = get_the_category(); $cat = $cat[0]; echo $cat->cat_name;?>

PHP Snippets for Header
<?php bloginfo(‘name’); ?> Title of the site
<?php wp_title(); ?> Title of the specific post or page
<?php bloginfo(‘stylesheet_url’); ?> The style.css file’s location
<?php bloginfo(‘pingback_url’); ?> Pingback URL for the site
<?php bloginfo(‘template_url’); ?> Location for the site’s theme files
<?php bloginfo(‘version’); ?> WordPress version for the site
<?php bloginfo(‘atom_url’); ?> Atom URL for the site
<?php bloginfo(‘rss2_url’); ?> RSS2 URL for the site
<?php bloginfo(‘url’); ?> Exact URL for the site
<?php bloginfo(‘name’); ?> Name of the site
<?php bloginfo(‘html_type’); ?> HTML version of the site
<?php bloginfo(‘charset’); ?> Charset parameter of the site
PHP Snippets for Templates
<?php the_content(); ?> Content of the posts
<?php if(have_posts()) : ?> Checks if there are posts
<?php while(have_posts()) : the_post(); ?> Shows posts if posts are available
<?php endwhile; ?> Closes the ‘while’ PHP function
<?php endif; ?> Closes the ‘if’ PHP function
<?php get_header(); ?> Header.php file’s content
<?php get_sidebar(); ?> Sidebar.php file’s content
<?php get_footer(); ?> Footer.php file’s content
<?php the_time(‘m-d-y’) ?> The date in ’08-18-07′ format
<?php comments_popup_link(); ?> Link for the comments on the post
<?php the_title(); ?> Title of a specific post or page
<?php the_permalink() ?> Url of a specific post or page
<?php the_category(‘, ‘) ?> Category of a specific post or page
<?php the_author(); ?> Author of a specific post or page
<?php the_ID(); ?> ID of a specific post or page
<?php edit_post_link(); ?> Link to edit a specific post or page
<?php get_links_list(); ?> Links from the blogroll
<?php comments_template(); ?> Comment.php file’s content
<?php wp_list_pages(); ?> List of pages of the
<?php wp_list_cats(); ?> List of categories for the site
<?php next_post_link(‘ %link ‘) ?> Url to the next post
<?php previous_post_link(‘%link’) ?> Url to the previous post
<?php get_calendar(); ?> The built-in calendar
<?php wp_get_archives() ?> List of archives for the site
<?php posts_nav_link(); ?> Next and previous post link
<?php bloginfo(’description’); ?> Site’s description

Only Show Children of a Category

The following example code generates category links, sorted by ID, only for the children of the category with ID 8; it shows the number of posts per category and hides category descriptions from the title attribute of the generated links. Note: If there are no posts in a parent Category, the parent Category will not display.

<ul>
<?php wp_list_categories('orderby=id&show_count=1
&use_desc_for_title=0&child_of=8'); ?>
</ul>

Remove Parentheses from Category Counts

When show_count=1, each category count is surrounded by parentheses. In order to remove the parentheses without modifying core WordPress files, use the following code.

<?php
$variable = wp_list_categories('echo=0&show_count=1&title_li=<h2>Categories</h2>');
$variable = str_replace(array('(',')'), '', $variable);
echo $variable;
?>

Include or Exclude Categories

To sort categories alphabetically and include only the categories with IDs of 16, 3, 9 and 5, you could write the following code:

<ul>
<?php
wp_list_categories('orderby=name&include=3,5,9,16'); ?>
</ul>

The following example displays category links sorted by name, shows the number of posts for each category, and excludes the category with the ID of 10 from the list.

<ul>
<?php
wp_list_categories('orderby=name&show_count=1&exclude=10'); ?>
</ul>

Display or Hide the List Heading

The title_li parameter sets or hides a title or heading for the category list generated by wp_list_categories. It defaults to '(__('Categories')', i.e. it displays the word “Categories” as the list’s heading. If the parameter is set to a null or empty value, no heading is displayed. The following example code excludes categories with IDs 4 and 7 and hides the list heading:

<ul>
<?php
wp_list_categories('exclude=4,7&title_li='); ?>
</ul>

In the following example, only Cateogories with IDs 9, 5, and 23 are included in the list and the heading text has been changed to the word “Poetry”, with a heading style of <h2>:

<ul>
<?php
wp_list_categories('include=5,9,23&title_li=<h2>' . __('Poetry') . '</h2>' ); ?>
</ul>

List Categories

NOTE: wp_list_categories() works in much the same way as the two template tags replaced in WordPress 2.1, list_cats() and wp_list_cats() (both deprecated).

Usage

<?php wp_list_categories( $args ); ?>

Default Usage

<?php $args = array(
'show_option_all'    => ,
'orderby' => 'name',
'order' => 'ASC',
'show_last_update' => 0,
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => ,
'feed_type'          => ,
'feed_image' => ,
'exclude'            => ,
'exclude_tree' => ,
'include'            => ,
'current_category' => 0,
'hierarchical' => true,
'title_li' => __( 'Categories' ),
'number' => NULL,
'echo' => 1,
'depth' => 0 ); ?>

By default, the usage shows:

  • No link to all categories
  • Sorts the list of Categories by the Category name in ascending order
  • Does not show the last update (last updated post in each Category)
  • Displayed in an unordered list style
  • Does not show the post count
  • Displays only Categories with posts
  • Sets the title attribute to the Category Description
  • Is not restricted to the child_of any Category
  • No feed or feed image used
  • Does not exclude any Category and includes all Categories
  • Displays the active Category with the CSS Class-Suffix ‘ current-cat’
  • Shows the Categories in hierarchical indented fashion
  • Display Category as the heading over the list
  • No SQL LIMIT is imposed (‘number’ => 0 is not shown above)
  • Displays (echos) the categories
  • No limit to depth
  • All categories.

Parameters

show_option_all
(string) A non-blank values causes the display of a link to all categories if the style is set to list. The default value is not to display a link to all.
orderby
(string) Sort categories alphabetically, by unique Category ID, or by the count of posts in that Category. The default is sort by category name. Valid values:

  • ID
  • name – Default
  • slug
  • count
  • term_group
order
(string) Sort order for categories (either ascending or descending). The default is ascending. Valid values:

  • ASC – Default
  • DESC
show_last_updated
(boolean) Should the last updated timestamp for posts be displayed (TRUE) or not (FALSE). Defaults to FALSE.

  • 1 (True)
  • 0 (False) – Default
style
(string) Style to display the categories list in. A value of list displays the categories as list items while none generates no special display method (the list items are separated by <br> tags). The default setting is list (creates list items for an unordered list). See the markup section for more. Valid values:

  • list – Default
  • none
show_count
(boolean) Toggles the display of the current count of posts in each category. The default is false (do not show post counts). Valid values:

  • 1 (True)
  • 0 (False) – Default
hide_empty
(boolean) Toggles the display of categories with no posts. The default is true (hide empty categories). Valid values:

  • 1 (True) – Default
  • 0 (False)
use_desc_for_title
(boolean) Sets whether a category’s description is inserted into the title attribute of the links created (i.e. <a title=”<em>Category Description</em>” href=”…). The default is true (category descriptions will be inserted). Valid values:

  • 1 (True) – Default
  • 0 (False)
child_of
(integer) Only display categories that are children of the category identified by this parameter. There is no default for this parameter.
feed
(string) Display a link to each category’s rss-2 feed and set the link text to display. The default is no text and no feed displayed.
feed_type
(string)
feed_image
(string) Set a URI for an image (usually an rss feed icon) to act as a link to each categories’ rss-2 feed. This parameter overrides the feed parameter. There is no default for this parameter.
exclude
(string) Exclude one or more categories from the results. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See the example. The child_of parameter is automatically set to false.
exclude_tree
(string) Exclude category-tree from the results. This parameter added at Version 2.7.1
include
(string) Only include the categories detailed in a comma-separated list by unique ID, in ascending order. See the example.
hierarchical
(boolean) Display sub-categories as inner list items (below the parent list item) or inline. The default is true (display sub-categories below the parent list item). Valid values:

  • 1 (True) – Default
  • 0 (False)
title_li
(string) Set the title and style of the outer list item. Defaults to “_Categories”. If present but empty, the outer list item will not be displayed. See below for examples.
number
(integer) Sets the number of Categories to display. This causes the SQL LIMIT value to be defined. Default to no LIMIT.
echo
(boolean) Show the result or keep it in a variable. The default is true (display the categories organized). This parameter added at Version 2.3 Valid values:

  • 1 (True) – Default
  • 0 (False)
depth
(integer) This parameter controls how many levels in the hierarchy of Categories are to be included in the list of Categories. The default value is 0 (display all Categories and their children). This parameter added at Version 2.5

  • 0 – All Categories and child Categories (Default).
  • -1 – All Categories displayed in flat (no indent) form (overrides hierarchical).
  • 1 – Show only top level Categories
  • n – Value of n (some number) specifies the depth (or level) to descend in displaying Categories
current_category
(integer) Allows you to force the “current-cat” to appear on uses of wp_list_categories that are not on category archive pages. Normally, the current-cat is set only on category archive pages. If you have another use for it, or want to force it to highlight a different category, this overrides what the function thinks the “current” category is. This parameter added at