get_the_category()
returns the array of WP_Term
objects. So,
// get all categories objects
$categories = get_the_category();
// get the first category name
if ( ! empty( $categories ) ) {
$category = $categories[0]->name;
}
$output .= '<li><a href="https://wordpress.stackexchange.com/questions/293636/" . get_the_permalink() . "https://wordpress.stackexchange.com/questions/293636/">';
$output .= get_the_title() . '</a> ';
$output .= $category ."https://wordpress.stackexchange.com/questions/293636/";
$output .= get_the_time('d M Y') . '</li>';
Related Posts:
- WordPress Multisite – global categories
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Can’t custom taxonomies have same terms (slugs) as categories?
- Using wp_category_checklist in a widget
- Activate Gutenberg in category-descriptions
- How to show subcategories in categories else show posts
- How would I increase the Author Role to be able to add a new category?
- How to remove the parentheses from the category widget
- Filter front page posts by category
- How to get the url to tag & category base set by the user?
- Exclude one category from get_the_term_list
- How to: 301 Redirect /category/ to /customname/
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- Root level category, tag, author and archive pages to work
- Number of posts in page – set per category and exclude sidebar
- Display one latest post from multiple categories
- Archive pagination causing 404 with permalinks structure
- Get a list of Terms for a specific category
- Get a variable from object in array [closed]
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- How Do I Merge Categories With phpMyAdmin
- Exclude Child Categories Using wp_list_categories
- Edit the markup of categories list
- Show category children, one level
- a-z list, categories and sub categories in loop
- Category slug $_SERVER[‘REQUEST_URI’];
- wp_dropdown_categories and custom taxonomy + custom post type
- Random taxonomy category list
- Linking products to categories
- How to remove “Category : …”
- Show all posts for a specific category/author
- Resort get_categories
- How to call custom category field data in theme?
- Query Posts Exclude Entire Category
- One Specific Category To Permalink
- Hide woocommerce category name from specific pages
- WordPress category widget only show categories with children
- Woocommerce custom category page with pagination [closed]
- Menus don’t work after 4.4 [closed]
- Custom post and category template pagination problem
- Multiple category selection in post, shows less important category in breadcrumb
- How to list all categories in three divs dynamically based on the quatity of categories?
- Grouping categories by genre
- how to “not” display new posts with a specific category on the main page?
- Limit categories and it’s subcategories for specific group of users
- show all WordPress categories in a page
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Category specific order
- Problems with my conditionals in single.php by category
- Recent post by custom select query
- WP_safe_redirect not working
- Do not show sub categories in the loop on archive-product.php
- Having a template per category? Bad for server overhead?
- Add custom code at start and end of all posts in a category
- “Virtual category page” based on a custom field filter
- Anchor tag generates blank href attribute using echo esc_url( )
- WordPress monthly archive category specific
- Get categories related to particular category
- handling the featured category
- Exclude the category of the current post
- Output Title of Post’s Current Category
- Related Post by category, but not current category child
- Excluding current category from sidebar’s post widget, elementor, query-id
- get list of category from a specific post with get_term()
- Show subChild categories
- Return all Tags and Categories in Separate List
- Featured Category or Special Category in WordPress
- How to show given products only using product id array from specific category page in woocommerce
- Using the slug of a custom post category as prefix for the underlying custom post slugs
- Change background image page header overlay for each category
- List non-empty categories from a custom post type
- Creating a linkable category list with post count
- Remove base category gives 404 error
- Woocommerce product catalog, products with different description
- Querying posts from two different categories while looping inside another loop
- How can I add metaboxs to Admin Bar?
- How to add Pagination to foreach loop to page
- Loop doesn’t work
- Getting Post Tags From Certain Categories
- How to get posts from many categories using WP_Query
- Getting page/category content to show up in my custom page template
- Show only one of the categories of a post in the breadcrumb?
- Wrong category being displayed in URL
- Check if a post is in specific category to show an icon
- Category slug in in loop always the same?
- How to populate a WordPress install with a lot of categories, quickly?
- Displaying posts by year
- How to get the post of category
- Logic for Nearby places with post and categories
- Display categories and their IDs
- Image menu showing categories in page
- Is it possible to know which category page the post was linked from?
- Category Archives: Show posts categorized in parent category only
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- How to control order when displaying child categories
- Trying to WP_Query a category
- hide_empty property not working when using get_terms
- sub-category showing up in wrong order in breadcrumbs
- Category Redirection Problem
- Hierarchical outline of posts