get_the_category()
retrieves WP_Term
objects for all the categories assigned to the post. You can combine that with wp_list_pluck()
to just get the slugs:
$categories = get_the_terms( null, 'project-category' );
$category_slugs = wp_list_pluck( $categories, 'slug' );
$category_slugs
will now be an array of slugs for the categories of the post.
Related Posts:
- Resetting post data to previous loop in nested loops
- Pagination returns 404 after page 20
- Make loop display posts by alphabetical order
- WP_Query: query posts by ids from array?
- get custom post type by tag
- pre_get_posts with get_posts
- Query Custom Meta Value with Increment
- Get attachment by slug
- Identify which loop you are hooking into; primary or secondary?
- Group posts by custom field
- Transient pagination not working properly
- get_posts() seemingly ignoring post_type
- Woocommerce custom loop to show all the products [closed]
- Exclude first 5 posts of specific categories in the main loop
- How to bring specific post to front of wordpress loop?
- How to show the posts of some category first, and then all other
- Pagination stops at page 6
- Paginated HTML Sitemap
- Posts loop with pagination on a single post page
- Why does the_content not work like others for a set post id?
- WP_Query Order by Specific Post ID First
- How to limit total number of posts in wp query loop?
- Using one WP_Query object within the loop of another WP_Query object
- Pagination is broken and I need help fixing it
- WP_Query on custom field and order results
- how to merge a WPQuery array with a PHP array and use the Loop to Output the result
- How to vary post loop results layout and resume?
- Get a post from other loop each n-posts in the main loop
- Loop returning only 1 result
- Where is the WP_Query instance instantiated (when working with themes)?
- WordPress Loop and $post
- WP_Query tax query part of slug
- posts_per_page not working for first page of pagination
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Excluding pages in WP_query using ACF
- reset to main loop doesnt work
- Some doubts about how the main query and the custom query works in this custom theme?
- Search form not working with custom query?
- Post loop for all taxonomy terms
- WordPress ignoring LIMIT / posts_per_page despite being in wp_query
- Stuck in the query loop
- Conflict with get_posts and the_content
- Only display post if published in last 24 hours?
- How to remove the most recent post from $the_query
- WP_Query loop else statement not executing
- Include current post into loop
- How to display the featured image for each post?
- How to provide meta_key array to wp_query?
- Check for the main query from the template
- Trying to retrieve random post, getting a page
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- has_excerpt() not working inside wp_query
- PHP – Loop custom post type categories within jQuery Tabs
- WP_Query with one category in args shows other categories
- Ordering posts by custom field and grouped by month
- Hiding carousel indicators if there’s only one post
- relation OR instead of AND – Filtered term ID’s in loop
- Compare “Main” post ID to ID inside wp_query loop
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Why does apply_filters behave different inside and outside a loop?
- Custom template for password protected page
- WP Query get only 1 post (sticky, not sticky etc)
- WP_Query not returning correct result with meta_query parameter
- problem with the loop
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- Function the_posts_pagination() not compatible with WP_Query arguments
- Prevent Duplicate Post Counted by Query
- Loop through array of pages
- How to show specify category template for both parent and child category
- Pagination inside the blog page not working
- Woocommerce featured products query no longer working
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- Custom Query Pagination not working on static front page
- query all posts published by certain user id
- I have 3 categories, i want to display on a loop the last 3 of every category
- WP_Query doesn’t works inside loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- View related categories in order of posts
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query causing links to not work
- Retrieving category pages from subcategory returns empty sets
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Show posts in category
- Both WP_Query and get_posts returning 1 post
- Iterate through ID’s in loop
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- An archive page without post format (just standard post)
- Custom post type archive organized by category
- No content found on page 2 of pagination with 1 post per page
- Pull Instagram images into an existing loop?
- Multiple loop for “featured” items returns wrong posts
- Pagination in custom query not working [duplicate]
- Help with showing text when something is entered in my search bar
- How to write a query-function as a query-shortcode?
- Print post data inside loop using theme content template
- First post outside of loop, homepage only?
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen
- How to get rid of extra Untitled Article in html5 document outline when using new WP_Query?
- after refresh the id that shows correct in first time click, changes to 1