Recommended Free Tools
Exclude a category in the query that builds the page, not with CSS. Use pre_get_posts to change WordPress’s existing home, archive, or feed query, or use a separate WP_Query with category__not_in when a template owns its own post loop. The value is an array of numeric category IDs.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
A category disappears from a WordPress page only when the query stops selecting posts in that category. Hiding cards with CSS leaves the posts in the query, can create empty spaces, and does not reliably fix pagination or feeds. The durable solution is to change the query arguments before WordPress retrieves posts.
As an Amazon Associate I earn from qualifying purchases.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Choose the query you actually need to change
First determine whether the page uses WordPress’s main query or a second loop created by a template. That decision determines the correct implementation.
| Situation | Use | Important detail |
|---|---|---|
| The normal blog, home, archive, or feed loop must omit a category | pre_get_posts |
Limit the callback to the intended front-end main query. |
| A page template creates its own list of posts | A separate WP_Query using category__not_in |
Keep pagination and loop handling in that custom query. |
You are considering replacing the main loop with query_posts() |
Do not use it for this task | Modify the existing query with pre_get_posts instead. |
The same exclusion argument can be used in both approaches. The difference is which query object receives it and who controls the loop.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Find the category ID
category__not_in accepts category IDs, not category names or slugs. A slug such as reviews will not work in this argument.
Find it in the WordPress admin
- Open Posts > Categories in the dashboard.
- Hover over the category, or open it for editing.
- Look at the browser address. The number following
tag_ID=is the category’s term ID. - Use that number in the PHP array, without quotation marks.
For example, if the edit screen contains tag_ID=12, the exclusion value is array( 12 ). If you need several categories, list each numeric ID: array( 12, 18, 25 ).
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesFind it in code
When the ID should not be hard-coded, WordPress term APIs can retrieve it from a known slug or name. Resolve the term before building the query, verify that the result is a valid term, and then pass its integer ID to category__not_in. The query argument itself still receives IDs.
Exclude a category from the existing blog or home query
Use pre_get_posts when WordPress has already created the query that will render the page. The hook runs after the query object is created but before the query executes, so changing its parameters here affects the posts selected for that request.
Basic front-end home/blog example
<?php
add_action( 'pre_get_posts', 'exclude_category_from_page' );
function exclude_category_from_page( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// Exclude category ID 12 from the blog/home query.
if ( $query->is_home() ) {
$query->set( 'category__not_in', array( 12 ) );
}
}
Replace 12 with the category ID you found. The early return prevents dashboard requests from being changed and prevents secondary loops—such as a sidebar or widget query—from inheriting the rule. The is_home() check targets the blog posts index; it does not mean every request that happens to display posts.
Exclude several categories
<?php
add_action( 'pre_get_posts', 'exclude_selected_categories' );
function exclude_selected_categories( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( $query->is_home() ) {
$query->set( 'category__not_in', array( 12, 18, 25 ) );
}
}
Each number is excluded from the same query. Posts assigned to any one of those categories are omitted from the result.
Free tools Windows power users keep installed
One-click scans. No signup required.
Target the correct request
Change the condition when the reader’s page is not the blog index. An archive, feed, or custom page can use a different conditional check on the passed $query object. The essential pattern remains the same: return for admin and non-main queries, identify the exact request, then call $query->set().
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
Do not assume that the site’s front page and its posts page are the same request. Check how the site is configured and choose the conditional that represents the page you intend to filter. If the requirement includes an archive or feed, give that request its own explicit condition so the exclusion is predictable.
Where to put the pre_get_posts callback
The callback must load before WordPress runs the target query. A small site-specific plugin is a durable location because it remains active when the theme changes. The active theme or child theme’s PHP code can also contain the hook when the behavior belongs to that theme.
Site plugin
- Create a PHP file in the site’s plugins directory with a plugin header.
- Place the
add_action()call and callback in that file. - Activate the plugin in Plugins before testing the page.
Keep the callback narrowly named and avoid declaring it twice. A duplicate function declaration can produce a fatal error, while a duplicate hook can make debugging confusing.
Child-theme code
If the exclusion is part of the theme’s presentation, add the callback to the active child theme’s PHP file. A child theme avoids losing the change when the parent theme is updated. Whichever location you choose, use the PHP syntax exactly and make sure the file is loaded on front-end requests.
Build a separate page loop with WP_Query
A custom query is appropriate when a page template deliberately renders its own list of posts rather than relying on the main loop. Pass category__not_in in the arguments and use the returned query object for the loop.
<?php
$posts = new WP_Query(
array(
'post_type' => 'post',
'category__not_in' => array( 12 ),
'paged' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1,
)
);
if ( $posts->have_posts() ) {
while ( $posts->have_posts() ) {
$posts->the_post();
// Render the post here.
}
// Output pagination for this custom query here.
}
wp_reset_postdata();
The paged argument carries the current page number into the custom query. Without it, a visitor can reach the first page but pagination may repeatedly request the wrong result set. Use the custom query’s own pagination values when generating links, and call wp_reset_postdata() after the loop so later template code sees the original global post.
Custom page conditions and templates
A page can contain a custom loop even when the site’s main query is a normal page query. In that case, changing pre_get_posts may affect the page request but not the separate list the template creates. Put the exclusion directly in the WP_Query arguments that produce that list.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Keep the scope explicit
Set post_type and other arguments deliberately so the custom loop returns the content your template expects. The category exclusion applies to the query you construct; it does not automatically alter unrelated loops elsewhere on the page.
Use the negative cat syntax when a query already uses cat
WordPress also documents excluding categories by prefixing their IDs with a minus sign in the cat argument:
<?php
$args = array(
'cat' => '-12,-18',
);
$posts = new WP_Query( $args );
Here, category IDs 12 and 18 are excluded. This form is useful when the query already expresses its category selection through cat. For code whose purpose is specifically to exclude categories, category__not_in is usually clearer because the intent is visible in the argument name and the values are an array.
Test the exclusion without breaking navigation
Test the request that readers will actually use, not only a single page while logged in as an administrator.
- Open the target page in a private window or while logged out.
- Confirm that posts assigned to the excluded category do not appear.
- Confirm that posts in allowed categories still appear in the expected order.
- Open the next and previous result pages and check that excluded posts do not reappear.
- If the requirement includes an archive or feed, test that URL separately; a home-page condition does not automatically cover it.
- Check a page with a sidebar, widget, or secondary post list to ensure those queries were not unintentionally changed.
When testing a custom loop, inspect the pagination links generated for that loop. They should preserve the custom query’s page number and continue to omit the selected category.
Common failures and precise fixes
The code uses a slug instead of an ID
Symptom: the category still appears, or the query returns an unexpected set of posts.
Fix: replace the slug or name with the numeric term ID. The argument is array( 12 ), not array( 'reviews' ).
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
The callback changes too many lists
Symptom: a widget, sidebar, or another loop loses posts that should remain visible.
Fix: keep both guards: return when is_admin() is true, and return when $query->is_main_query() is false. Then add the narrowest page condition needed for the target request.
The intended page is unaffected
Symptom: the home page changes, but an archive, feed, or custom page still shows the category.
Fix: the conditional probably describes the wrong request. Replace is_home() with the appropriate check on the passed query object, or move the exclusion into the template’s separate WP_Query.
The PHP never runs
Symptom: no page changes, even though the code appears correct.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Fix: verify that the file is in the active site plugin or active/child theme, that the plugin is activated when applicable, and that the callback is loaded before the query executes. Also check for a syntax error or a function name collision.
Pagination loses the exclusion
Symptom: page one is filtered, but later pages repeat posts or show excluded posts.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Fix: use a custom query’s paged argument and generate pagination from that query. For the main loop, modify the existing query with pre_get_posts rather than constructing a second, competing loop.
The developer used query_posts()
Symptom: pagination, globals, or other template behavior becomes unreliable.
Fix: remove the query_posts() replacement. Use pre_get_posts to adjust the main query, or create a dedicated WP_Query for an independent list. WordPress documents those approaches as better options for this purpose.
Decide whether the category should be excluded everywhere
An exclusion can be intentionally narrow. Filtering only the blog index leaves the category available on its own archive and in feeds. Filtering an archive or feed requires an explicit condition for that request. Before coding, write down the exact destinations that should omit the category:
- the posts page or home query;
- one or more category or date archives;
- feeds;
- a page template’s custom list; or
- several of these, each with a separate condition.
This list prevents an apparently successful fix from silently changing a destination that editors still need. It also tells you whether one guarded main-query callback is sufficient or whether a custom loop needs its own arguments.
Recommended implementation checklist
- Identify the exact page, archive, or feed request to change.
- Record the category’s numeric term ID.
- Choose
pre_get_postsfor the existing main query orWP_Queryfor a separate loop. - For
pre_get_posts, return early for admin requests and non-main queries. - Set
category__not_into an array of IDs. - Use
pagedand query-specific pagination for a custom loop. - Place the code in a loaded site plugin or the active/child theme.
- Test the target page, additional pages, and any archives or feeds that are meant to change.
- Do not replace the main query with
query_posts().
Why query-level exclusion is the right layer
The category rule belongs where WordPress selects posts. A query-level exclusion keeps result counts, pagination, and rendered markup aligned because unwanted posts are never handed to the loop. It also lets you choose scope: one main request can be filtered without altering every secondary query, while a custom template can apply a different rule to its own list.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
That separation is the key to maintaining a site with multiple post lists. The argument expresses what content belongs in a particular result set; the conditional checks determine which request receives the rule; and the loop remains responsible for rendering and pagination.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




