global $wpdb;
$post_ids = [1,2,3] //Array of all post ids
// get all category id's based on post ids
$result = $wpdb->get_results( " select term_taxonomy_id from " . $wpdb->prefix . "term_relationships where object_id in (implode(",",$post_ids)) );
Related Posts:
- Get the children of the parent category
- How to remove the term “category” from category pagination?
- How to add featured image for category (without a plugin)?
- Category archive by year with permalink support /category/YYYY
- Force WordPress to Show Pages Instead of Category
- How do I get the category URL from get_the_category?
- How do I use the same post slug for different Categories?
- Default WP Gallery – show only galleries of a certain category
- How to tax query X number of posts related by tag first, then by category if not enough in tag-related
- Exclude sub category posts from category display
- How to hide a specific category posts in my monthly archive?
- Is there a way to remove categories in bulk?
- Automated adding of one tag to all the posts in a category
- Is it possible to put next and previous category links?
- Custom category template pagination problem
- Deleting All tags except categories Wp database
- Action hooks returning old category instead of new category
- Category checkboxes in upload modal
- Getting category before saving post
- How do I change the sql query for wp_get_archive()
- How to mass-insert categories?
- New categories are now going to 404s
- How to put enctype=”multipart/form-data” in categories form?
- What is the advantage of using header-catname.php over is_category(‘catname’);?
- Custom WP_Query for current category (in category.php)?
- Why is get_the_category() saying that I have two categories?
- Custom sidebar on category pages
- Insert Into Sub-child Menu
- How do I get the category slug from wp_dropdown_categories
- Change the category of all posts in it
- Search Posts / Pages with multiple options?
- How to display only posts assigned to a particular, isolated, subcategory
- How to hide some categories in category list under post in wordpress?
- exclude categories from search results
- Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts
- How to categorize posts under Category 1 and Category 2 which are separate lists of categories, and display them as separate lists in widgets
- Why don’t posts show up in my categories on the frontend?
- Creating Category Specific menus
- Category archives with monthly pagination
- Older entries link within category page
- Two separate portfolio pages [closed]
- How to do some action weekly?
- How to hide child categories from displaying
- How to allow Category Title to use tags?
- List Child Categorie and hide the parent
- Child categories doesn’t echo if it doesn’t contain at least a post
- Some categories missing on wp-admin/edit-tags.php?taxonomy=category
- Multiple selection for wordpress widget
- Show different title on category page
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- function query_posts disabling current_page_menu class
- Using if statement in index.php instead of creating separate template files
- Problem with multiple loops in wordpress theme
- How to get category names in post_class?
- output only if within a combination of two cats
- Panoramica Theme Portfolio
- Filter categories/tags to display in multiple metaboxes for selection in back-end
- Check is category parent with ids from the childs – get_term_children
- wp_list_pages() not showing on posts
- Are tags different than categories?
- list all child categories that apply to current post even if those cats are empty?
- WordPress Category Question
- How to filter post from categories only if the posts appears in one of them, not the other?
- Getting the posts list visualised in categories tree
- wp_dropdown_categories() show elements checkbox
- Conditional widget for theme template file
- Help to display the current categories and tags of a post
- Private categories in WordPress
- How to show the clicked category related posts on category detail page?
- Why is URL Slug Saving Differently From How It’s Been Defined?
- How to set acf color field as background color to product category
- How to add all subcategories as submenu in WordPress menu
- Related to genre and category
- Get permalink to latest post in category
- How to noindex, follow a specific category wordpress?
- get taxonomy list in a page in the wordpress
- Is there a way to allow users to customize their feed view?
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- restrict category to only logged in User
- Category and tag urls return 404 error
- Removin /page/2 from pagination
- How to exclude category and post_tag taxonomy while displaying custom taxonomy?
- get parent_category class in loop
- Group Posts by First Letter of Title categories
- Display all of a post’s categories except the current category
- Alphabetize all but one category
- How to make 10 post of one category
- How to create a category or tag available exclusively to the admins and not to the users?
- Printing direct descendants of a category with WP_Query
- wordpress category.php query for featured news item, broken pagination and repeating posts
- Listing category
- Echo class depending on Parent category
- Query pages by category
- List all authors by matching custom meta data on a category page
- Page view: Sorted by categories
- Anyway to hide a Category in the Categories section when adding/editing a post in WP Admin?
- Showing one post from each category, paged?
- Custom permalinks structure
- Weird html output of single_cat_title – is not inside of the html element?
- Images as Categories