You can use the same code, you just have to find the id of your category by slug.
Yo can do this by adding :
$idObj = get_category_by_slug('category-slug');
$id = $idObj->term_id;
And then put $id in your excluding array.
the function is documented here : wordpress documentation
Related Posts:
- exclude multiple terms using get_terms() function
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Allow authors to post only in categories they create in WordPress
- Add custom field to attachments in a specific category
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Put a link to a category round a hard coded A HREF
- Check if Product is in a Specific Category in Functions.php
- Get posts with at least one category in common with current post?
- Woocommerce – remove product from category
- get current product name in functions.php
- get post based on category chosen in drop down – The ajax method
- Swapping wp_dropdown_categories function with wp_category_checklist
- What is an equivalent of single_cat_title for getting the slug of the category?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to pick the default selected value in wordpress dropdown?
- Get page that displays all children of taxonomy parent
- Redirect to another page using contact form 7? [closed]
- Dilemma of Populating all the categories in a drop down list
- Edit the_category (); for a hierarchical display
- Displaying posts based on category
- How to get current post category details inside “loop”?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Allow two posts (from different categories) to have the same slug
- Dropdown category field inside repeatable metabox
- Get nice name of category from slug (remove dashes of category)
- Display Visual Composer shortcode if a post belongs in specific categories
- Get parent category name when only child category is applied to a product
- How to move a post from one category to another
- Notice: Undefined variable
- Populate Posts based on category selected using AJAX that means without page refresh
- All categories options or All categories not Populating
- Exclude a category slug on pagination
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- PHP get_category() function redeclared
- WordPress using get_term to retreive slug not working as expected
- Get category id for a custom category and display it in a class
- Trying to see if page is category or single and displaying title with appropriate heading tag
- get_category only returning details for ‘uncategorized’
- Displaying categories
- How to insert the first letter in uppercase [closed]
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Exclude a category ID from the following function
- Is it possible to disable a function of a parent theme?
- Hide old attachments from wp media library
- PHP – redirect https to http and www to non-www
- Need to get specific data from array
- Categories Template Assistance
- Sort registered users by post count? (inside admin dashboard)
- How to change a public function inside a class of a plugin?
- Function set default image when image not present
- WooCommerce – Reset quantity input field when variation changes
- Query all posts of a custom taxonomy term
- Trying to establish connection to External Database
- WordPress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs
- Login/logout in header
- How to put “Read more” link in Custom Excerpt inside p tag?
- Error when adding excerpt to the content through functions.php
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get users that likes the post
- How to abort saving data in save_extra_profile_fields function WordPress?
- Get the date of the className or classID
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- Exclude category
- What exactly do this function declared into functions.php file of a WP theme?
- Display Data in Table from External Database in WP using Shortcodes
- How to check if a Customizer setting is set?
- Get latest post from all categories except one
- Co-Authors Plus: How do I get all authors with a query?
- Why i can’t get custom fields value or post ID via Ajax?
- How to reference PHP in Javascript
- Fallback image URL if no featured image exists via a shortcode function
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Deactivate a plugin on wp version
- making php value numeric
- WP insert post Redirect after function has executed
- How to assign page id with array in page_scheduled_event
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- How to Send Pingbacks for all Posts in WordPress?
- HTML comment cause issue in functions.php script root
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Rewrite rule not working, but only when parameter is text
- Add element after navigation element title don’t works like I expect
- Get Billing Email from WooCommece Checkout and Pass to Fullstory JS
- How to delete specific element when it is not homepage?
- How can I include tags in wordpress search without a plugin
- get_category display only 1
- How can I display a query in a page?
- Using catch_that_image() for galleries?
- Make an array listing custom taxonomy
- Conditional Content Display
- Password form redirection to belonging post
- How to add margin underneath woocommerce total price amount -> productpages
- Whats wrong with my code? Need To add String to shortcode? [closed]
- add if statement to the featured image