I think the problem is that you have some posts already set as sticky and you don’t want to have to go back through and resave them. That being the case you just need to the remove the post ID
s from the “sticky” option.
function unset_sticky_for_category($cat) {
$sticky = get_option( 'sticky_posts' );
$sp = new WP_Query(
array(
'fields' => 'ids',
'post__in' => $sticky,
'cat' => $cat // your category to un-sticky
)
);
if (!empty($sp->posts)) {
$sticky = array_diff($sticky,$sp->posts);
}
update_option('sticky_posts',$sticky);
}
unset_sticky_for_category(16);
You should only need to run that once, so long as the code above is preventing new posts in the chosen category from being set to “sticky”.
Related Posts:
- Using categories & “stickyness” together
- Sticky posts on home page, search, tag and archives without plugin
- How to make all posts in a category sticky?
- Sticky Posts Not Sticking to Top of Category Archive
- Get sticky post from category?
- “Sticky” posts for each category (archive.php)
- Stick multiple posts in a single category
- Sticky posts not working when a specific category is set
- Sticky post for each category on category pages [duplicate]
- How to display sticky or latest published post on the current category page it belongs to?
- Category sticky latest
- How do you get sticky posts to work with categories?
- How to display only sticky posts on category pages?
- WooCommerce: List All Categories
- How can I hide a category from Contributors in the edit/add new post screen?
- Category page doesn’t use category.php, instead it redirects to homepage
- Multiple post categories – single permalink
- Wrap Post count in a span
- wp_nav_menu not appearing for a couple pages
- How to exclude uncategorized from permalink structure /%category%/%postname%/
- Create product category and keyword search form in woocommerce? [closed]
- Saving two categories from two dropdowns in front end posting form
- Display one category in one page
- How would you create a “weekly” archive?
- Exclude most recent posts from specific category in wp_query()
- Display all posts with same title
- Show children of top level category only
- Category Search functionality on category metabox (wordpress admin)
- How to get category id in single.php wordpress?
- how do I filter single_cat_title to remove all instances of a particlular word
- Dropdown category filter
- Category page shows Oops! That page can’t be found
- How to find the number of Tags a post has?
- How can I enable a TINYMCE rich text editor in the admin interface?
- WordPress order categories by ID
- ACF: Display category name using taxonomy field
- query order by category
- How to make 2 tag feeds show up on 1 page?
- Shortcodes not working in category or tag description
- Best way of getting WooCommerce category path
- Display the last post by each category?
- Post in multiple categories
- Order categories by name or view count
- Access current post parent and sub category
- Give a page priority over a category that has the same name?
- Filter $cpt categories to omit certain category
- How to rewrite the post URL according to the category?
- ajax for filtering posts by category in wordpress loops
- Create category post shortcode
- Question on using custom structures for categories
- How to add orderby parameter for sorting on category.php
- delete category name in the pages
- Wrong category nice name is displayed on archive page
- Tags Instead of Category
- Cannot filter categories by parent category
- Redirect year month day postname permalink structure to category postname structure
- Remove category link
- javascripts files not linking to my category slugs?
- Generating a feed of all but one category of posts
- Pretty URLs with Categories and Tags
- Select posts that match multiple category names, must match all categories listed
- How can i display category title over thumbnail?
- How to display the 5 latest post titles but allow only 1 in there of a specific category
- How to add categories using mysql
- Posts made to category don’t show up (do show up on frontpage)
- How to use category slug with a regular page
- Display all categories but only if they have posts in them that have a specific tag assigned
- How to fix select filter on category
- wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
- Show audio player only in specific post type category
- Check with Jquery if second level checkbox from categories are checked
- display current portfolio categories from a specific parent
- Regarding Tags And Categories
- How to show entries related to main category
- selecting categories that have products with tag/category
- How to get WooCommerce Product Categories and its children’s children?
- How to hook into creating a category?
- Media Library Category Exclude Tree
- When category name and title are the same … WP will select archive.php instead of single.php
- Re-coding category-template.php to go to custom URL
- Category removal – Portfolio Category:
- How to display child-category PAGES on a category page
- How get all media from a posts category by db?
- Cant get unique_array() work on get_the_category() foreach loop
- Show One Level Category id
- get_categories returns top-level categories instead of child categories
- Show posts from all categories
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- how to Specifies an author / editor to edit one category only?
- Show one same template for two category
- My Query is getting the wrong data
- Formating content in category.php
- How to use Greek characters/letters in a query?
- WordPress Loop Prob
- Display post content from category name using ajax
- WooCommerce category display in custom page
- How to display the category featured images [closed]
- Echo Category In Loop
- Custom EndPoint not working when strip child category in URL
- How to add custom prefix before category base for category page URL?