Get tags related to wordpress category
October 13, 2009
Do you noticed there is no native way to retrieve tags based on the wordpress category. But if you want to be able to get tags related to one (or more) specific category, just insert the following function in your theme’s functions.php. Here is the function you have to paste in your function.php file: function get_category_tags($args) { global $wpdb; $tags = $wpdb->get_results (" SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link FROM wp_posts as p1 LEFT JOIN wp_term_relationships... [Read the full story]
Get tags based on the wordpress category
June 27, 2009
Althought WordPress allow you to do lots of things by default, but how to retrieve tags based on the category? Just paste following code wherever you need to display the list of tags that are specific to a particular category. Note: You can replace the category name on line two. <?php query_posts('category_name=wordpress'); if (have_posts()) : while (have_posts()) : the_post(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $all_tags_arr[] = $tag -> name; //USING... [Read the full story]
Display list of wordpress categories in two columns
May 21, 2009
Usually in WordPress, the following code is used to call the categories list (you can find it in one of the sidebar files): <?php wp_list_categories(); ?> Normally when the list of categories is displayed in the sidebar or on any part of the theme, it displays in a single column. Through the following hack, you can split your categories list evenly into two or more columns which can save space and not make your pages longer. Now, we will try and split the categories into two columns. Simply paste the following code... [Read the full story]
Exclude Certain Wordpress Categories from Being Searched
March 18, 2009
You may not want all of your categories to appear in your search results. For example, if you’ve set up a sidebar asides category, you may not want those short snippets tangling up with your results. To remove a category, first open up your theme’s functions.php file (Or create a blank file with that name if your theme doesn’t have one); Then paste the following code at the end: <?php function SearchFilter($query) { if ($query->is_search) { $query->set('cat','8,16'); } return $query; } add_filter('pre_get_posts','SearchFilter'); ?> Simply... [Read the full story]
Disable search engine indexing on a particular category
January 25, 2009
How to disable search engine indexing on a particular category? First get the ID of the category you’d like to be not indexed by search engines. In this exemple, I assume your category id is 18. Open your header.php file and paste the following code between the <head> and </head> tags: <?php if ( is_category('18') || in_category('18') ) { echo '<meta name="robots" content="noindex">'; } That’s all. With the above code, we made sure that no post from category with the ID 18 as well as category... [Read the full story]




















