get_the_category
should be returning all of the categories for your post, but you are only picking one of them, the first one, when you do this– $category = $category[0]->cat_ID;
. Instead of that line try:
$allcats = array();
foreach ($category as $cat) {
if (29 != $cat->cat_ID && 35 != $cat->cat_ID) {
$allcats[] = $cat->cat_ID;
}
}
$myposts = get_posts(
array(
'numberposts' => 5,
'offset' => 0,
'category__in' => $allcats,
'post_status'=>'publish', 'order'=>'ASC'
));
Related Posts:
- List all subcategories from category
- Get the children of the parent category
- Remove parent category from permalink? Basically only have the child category?
- How to remove the term “category” from category pagination?
- Force WordPress to Show Pages Instead of Category
- Display all posts in category, with specific tag posts at top
- Send an email when custom post type category is changed
- How to Set an Individual Homepage for Each User?
- Is there a way to remove categories in bulk?
- Remove specific category from a post
- Is it possible to put next and previous category links?
- Custom category template pagination problem
- Getting category before saving post
- How do I change the sql query for wp_get_archive()
- Woocommerce – Get product category 2nd level category
- Hide post meta data on a specific category
- New categories are now going to 404s
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- How to prevent empty category to list content of sub categories?
- “Reversable” and “Re-useable” Subcategories (or other taxonomic structure)
- Is it possible to have WordPress not recognize category URLs?
- Disallow categories from this MySQL query
- Use a wordpress page to display a certain category
- Insert Into Sub-child Menu
- How to list child categories?
- Search Posts / Pages with multiple options?
- Creating gallery with taxonomy images plugin?
- Full text articles in the rss feed (i.e. without the more tag)
- Get Tags specific to Category using WooCommerce plugin
- WordPress category page redirects in .htaccess not working
- Category archive rewrite rule to include category/subcategory?
- How can I automatically display a visual archive of subcategory posts [and thumbnails] separate from Parent category?
- The default code for “posts_nav_link” on category.php isn’t working
- Change thumbnail image depending product category
- How to organize custom categories for filtering and selecting
- Woocommerce custom category pages
- Custom sub taxonomy order by
- get_next_post set the category
- Different menu navigation per category
- category doesn’t showing up in admin
- Get category URL knowing it’s id
- Have multiple category queries from the URL been fixed yet?
- How could I know all the categories from post?
- How to make subcategory for custom post and and display?
- Create menu locations for each category in wordpress
- Conditional loop for category
- How to make the ‘delete’ button inactive on some categories?
- Notice: Trying to get property of non-object in : custom fields category
- Array: What is this value based on?
- Thumbnail for categories / taxonomies plugin?
- Pagination for query_posts();
- echo get_post_meta of all post in a category to fill up a select field
- Show testimonials based on post category matching product name
- WordPress list categories dropdown with parent-child relation and child under it’s parent
- How to Link to Most Recent Custom Post of Same Term
- WP REST API not retrieving all categories
- Category page not showing
- How to only show parent categories in sidebar
- Change RSS format for specific categories
- I need to exclude from a query a category and a few custom taxonomies
- Displaying a custom field in Category Archives
- List post only under the category, exclude child category content
- Custom Portfolio Page
- Custom Fields Value As Taxonomy
- Detect category choice for posts with multiple categories
- wp_insert_link not working
- Redirect Problems with Archive Page and GET variables
- Different size video display for category page (smaller) & detail page (larger)
- Adding tinymce to Custom Field boxes on Category edit page
- wp_list_categories : how do I sort by ID when IDs are not sequential
- Showing different posts on category pages
- How to exclude certain categories showing in Gutenberg?
- How to redirect to category page if page does not exists?
- Display the articles of a category by role
- Remove “Category:” from Post meta
- restrict category to only logged in User
- Category and tag urls return 404 error
- Default category isn’t saved in database
- Dynamically creating content on custom URL without getting 404
- Removin /page/2 from pagination
- get parent_category class in loop
- Category foreach Paging
- Display all of a post’s categories except the current category
- Alphabetize all but one category
- One category not displaying template updates
- How to display only category of blog without custom code?
- 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
- Matching usermeta at registration to categories of content
- wordpress category.php query for featured news item, broken pagination and repeating posts
- How do I hide posts in a category from all listings but still allow the posts to be viewed?
- Form Value of drop down category + Translation of ‘show option none’
- 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
- How to display posts by author in a separate page, other than author.php?
- One color to category link depending on category ID
- Show subcategories and hide posts or show posts if not exists subcategories
- How to remove the category from the url only for a specific category of articles on wordpress