If you take a look at the category parameters of WP_Query
, you’ll see that you can use either cat=-12
or category__not_in' => 12
to exclude a category with ID 12 in your custom query.
I just also want to point out a few things here. showposts
is depreciated, you should be using posts_per_page
. Also 'showposts=6' . '&paged='.$paged
is wrong. You should just use &
between your parameters. So you should do something like this 'posts_per_page=6&paged='.$paged
To conclude, to exclude the category ‘Tour’, which is what I presume from your code, you can do change this line
$wp_query->query('showposts=6' . '&paged='.$paged);
to
$wp_query->query('posts_per_page=6&cat=-' . $category_id . '&paged='.$paged);
Related Posts:
- Excluding a category from wp_query breaks recent post widget
- How can i listing current category and Featured Category post list?
- single.php fires more than once after clicking on any post to view with different post id each time
- Display by Category in Admin
- Search for categories
- Redirecting thousands of posts that currently have no category in their permalink when changing permalink structure to include category
- Customize permalink wordpress category id
- Automatically Assign Author to Category [closed]
- Custom Pages for Woocommerce Product-Category Pages
- polylang + category/tag custom language link
- How to password protect a category page / not posts?
- How to display taxonomy images with wp_list_categories?
- Using arbitrary paths in page urls
- background images WP Supersized on homepage
- WordPress “Categories to tags converter” not working. Pointing to import.php instead
- How do I apply style to each category of a list?
- ACF: post query, hide duplicate values [closed]
- Redirect to another page using contact form 7? [closed]
- Recent posts per category loop?
- How to obtain the recent posts without their content in an efficient way?
- Render content of multiple pages and their descendants
- order posts by `meta_key`, Does not display posts that does not have `meta_key`
- How do I rename a category in the menu bar only?
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- Is changing post from category in a large blog a good practice?
- Best/Correct way to add an option to a category
- How to set category correctly for a custom post created by a remote API call?
- .php file for woocommerce edit category? [closed]
- check uncategorized category by default
- Mutliple users editing single document in wordspress
- How to add category and subcategory in WordPress custom code?
- How to display a number of posts based on a Advanced Custom Field (ACF)
- WooCommerce Hiding A Certain Category From Being Displayed On Single Product
- How can recognize post’s category?
- Categories from front-end, checkbox selection doesn’t work
- How to get Recent Post From Each Category with Thumbnail?
- Category “same post” retreive and display
- Add a new category for posts
- Import Recent Posts Only and Ignore old ones if exist
- How to overwrite the category template in a plugin
- How to hide featured images of all posts falling under the same category in wordpress?
- how to show all posts of each category in pages
- Custom Post Type same name as Category
- Visual composer custom element error
- Display posts by alphabetical order
- How to display the category name in the tab and post inside the tab in WordPress?
- Adding custom post category to categories widget
- Custom Post Type with Sequence ID
- WordPress default post categories meta box widget
- How to display category list with category featured image
- Getting the same post on my related post
- custom post type get_posts() function not work
- Precheck fields when I add a new post
- The styles in the recent posts widgets plugin not working
- What plugin would make this happen? If is the theme
- automatically set random featured image by category in wordpress on post
- how can I edit the HTML of yith ajax product filter
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Unset plugins on front-end belonging to specific category
- WordPress Categories as a Grid
- Trying to remove a couple categories from shop page
- How to allow editors to only edit certain categories?
- Category as Subdomain for One WP Install
- Taxonomy Category Icon on index page
- Woocommerce categories displayed on every category and shopping page
- woocommerce product search based only title
- Ajax Load More on Hierarchical Categories
- Sub Categories in drop down menu
- How can I display a list of only categories which are marked as ‘featured’ in the backend?
- Related post based on 2 categories
- View more posts of a sub-category
- How to insert category name above post title in a featured pages plugin?
- how to repeat taxonomy in different places on wordpress
- trying to create simple plugin to filter categories from all authors
- Displaying saved category checked in a plugin?
- WordPress Categories from Plugin
- Showpost and last
- Is it possible to setup Category wise Subsciption?
- How to use categories in the URL with Advanced Custom Fields?
- get post excerpt by query
- Filter EVERY category link with my plugin
- Category archive in menu
- CSV file header
- Find And Add Category to Posts
- Retrieve post thumbnails
- WP-Snap too slow (caused by WP_Query?)
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- Pagination in category
- How to add character to content of post?
- Editing “Kahi’s Highlight Used Categories” plugin code – highlighting parent and child category in post page
- How can I add the custom taxonomy categories to the posts and pages?
- WordPress plugin not eching popular posts
- Twitter List Tweets and Delicious Links as Posts
- Display static pages instead of category, in code
- WordPress “Categories to tag converter” not working on imported Blogger posts
- wp_insert_post_data filter to set category
- What happened to WP No Category Base?
- 404 not found problem with URL rewrite custom category
- Is there a way to combine categories and their hierarchy into the admin listing page?
- Automatically set posts to NoIndex depending on category?