Exclude Categories in Search Results in wordpress

Below  is the code  to does not show  the posts from category 9,14 during  search.

<?php
$page  = (get_query_var('paged')) ? get_query_var('paged') : 1;
$s = get_query_var('s');
query_posts("s=$s&cat=-9,-14&paged=$page");
?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php   the_title(); ?><br /><br />
<?php endwhile;endif;?>
<?php next_posts_link('&laquo; Old Updates') ?>
<?php   previous_posts_link('Latest Updates &raquo;')

Removing The Title Attribute From wp_list_categories & wp_list_pages

Use  Exact Below code for  categories  and pages.

wp_list_categories:

<?php $title_free_cats = wp_list_categories(‘echo=0’);

$title_free_cats = preg_replace(‘/title=\”(.*?)\”/’,,$title_free_cats);

echo $title_free_cats; ?>


wp_list_pages:

<?php $title_free_pages = wp_list_pages(‘echo=0’); $title_free_pages = preg_replace(‘/title=\”(.*?) color: #000099; font-weight: bold;”>\”/’,,$title_free_pages); echo $title_free_pages; ?>

Exclude category from RSS feed in wordpress

To exclude category in wordpress rss feed.

you can simple write.

<a href="<?php bloginfo('url');  ?>/feed?cat=-1&cat=-2">(RSS)</a>

or   you can simple write below code in your theme function.php
to   exclude category categories.


function excludeCat($query) {
 if ($query->is_feed) {
 $query->set('cat','-1');// for   multiple use with , eg-  -1,-2,-3
 }
return $query;
 }
add_filter('pre_get_posts','excludeCat');
Page 1 of 212
eXTReMe Tracker