You need to do a foreach
for the get_the_category
Something like:
while ($my_query->have_posts()) : $my_query->the_post();
$x = $my_query->current_post + 1; //you can use this to count instead
$categories = get_the_category();
foreach($categories as $category) {
if ($x == 1) ...
//rest of your output
// remember to us $category->cat_name; instead of what you have above
}
Related Posts:
- Duplicate posts in paginated results
- Avoid WP_Query’s duplicate posts with taxonomies
- Duplicate posts on archive page
- Prevent duplicating specific column from database table
- Get date of last update outside of loop
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- Show scheduled posts in archive page
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- If Loop has odd number of posts on last page Custom style for last post in it
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- The Loop in Static Page
- How can I use get_permalink() outside the loop?
- multiple loops with pagination on the same page
- Loop through all media library images and return those where caption contains the text carousel
- Custom search form to display users only
- Multiple loops on the same page removing post tags
- Pages inside a page (with thumbnails)
- How to make post content from each post display within the same div
- How to order posts by meta_value created inside loop?
- How to get_posts where ‘menu_order’ is more than 0/zero?
- WordPress Redirects on Install
- How to return only one instance of each, from the entire loop
- Problems with loop
- Repeating Loop on my Posts Page
- Combining action and filter?
- Calling & display certain product category loop and pagination on the homepage
- Display Authors in a grid loop
- Infinite Scroll and DFP
- Blog’s post count cause irratic behavior
- Sanitize Custom Field Value in Meta Query
- Default ‘post’ post type archive slug?
- show random image in loop if image is not set
- Get Page content to displayin Bootstrap Modal
- Pagination – works on local but not live dev!
- need help looping add_action in wp
- Does WordPress Loop have a function like Shopify’s cycle?
- How to show more random posts if Tag has less than 3 posts
- How to display pending posts on the homepage only for editors
- Add leading zero to current post display [closed]
- Distribute Gallery Images Every nth in Loop
- WordPress Image Slider Looping Title Not Working
- Output meta into arrays
- Is there any good reason for two CSS files to @import each other?
- Adding div after every two post on main loop! Why will first post not get counted?
- Moving wordpress to different url/server creates redirect loop
- Second Loop Showing Only One Post on Single Post Page
- Random post link generator messes up the loop
- Modify loop output for a specific list of categories
- how can i order the category by date
- Change position of entry title
- Print the whole page?
- excerpt not showing up
- Pagination for two loops
- Announces with different formatting dependently on a number
- Override orderby to create list of users by custom meta_value
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- List page is showing 404
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Duplicated tag in loop
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Loop two different category WP_Query
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Transient not working for external data
- adding tax_query to $query_string
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- Remove posts_orderby filter then add it back in
- the_title() Returns the page title instead of the post
- WP update_post_meta link loop
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- How to add excerpt in loop in Twenty Eleven theme?
- show posts from one category with comments only
- Exclude Authors based off date of last post
- How to implement template file and the loop
- Show only posts from todays date [duplicate]
- I need to update the post query? [closed]
- Multiple loop with pagination in same page
- Why did my most recent article fall behind an older one on my site?
- wp_mail sending only once inside foreach loop
- How to use orderby on meta_value when using Pods custom database table storage
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop