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
- How to make a image-size selected by default in Media upload – WP v3.5
- Hide main div if wp_nav_menu is empty
- How to draw media details for Isotope gallery using Photoswipe
- retrieve thumbnail from post ID of best selling product in category
- Custom HTML structure in wp_list_categories
- show limited tags in an article
- Using a function written in my functions.php file within the header.php file
- Error: array_map(): Argument #2
- Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products [closed]
- Can I change a variable in a content part while calling it?
- Display all categories including sub categories
- Shortcode return function with link href inside PHP
- How to use transient in this code for related post?
- Function not working at one place
- foreach loop still echoes array
- dynamic dependent select dropdown
- Setting default category base on theme activation
- Noscript not working as it should in wordpress site
- Content filter won’t work
- Why does the post_type_link hook everything twice?
- use loop to return blog details
- Fetching Initials of the Commentator in the WordPress Website
- Missing a text-domain esc_attr_e
- Extract and display user infromation on an automatically created page
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- is user member of a group, show them categories [closed]
- How can I assign separate stylesheets to different pages?
- Using multiple variables to assign categories to an array
- Execute PHP code only with specific user role
- WP Container Displaying Only on First Page of Archive
- PHP function for horizontal Woocommerce thumbnails and badges
- Show sidebar only to author of post
- how to add custom select field to wordpress edit page
- Create category after theme setup and modify the default one
- PHP/CSS: Shortcode won’t display correctly, and only displays in the head (before content)
- WordPress load javascript file if something… (after the page is loaded)
- Add class for the_post_thumbnail_caption()
- Wrapping shortcode content in a span or link
- problem with category menu, it doesn’t want to show link
- Weird Behaviour: Not all WordPress Posts appearing
- Adding ID to a Listing but not inside WP_Query while
- WordPress display name string manipulation
- which table updated after logout?
- Accessing WordPress Functions get_permalink() in Vanilla PHP?
- How to return a Boolean for a page that is a subpage thru its name?
- Saving User Input to PHP Variable
- Undefined variable notice [closed]
- Alternative to php echo within code
- Add multiple HTML attributes to an Elementor button
- Automatically change insurance quantity based on cart total [closed]
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- /page/2/ redirect to 404
- How to pass value to add_filter wpcf7_form_tag from another function?
- hiddenQuestions.find is not a function