First of all, remember that a post can have multiple categories, so you’ll have to handle an array and then print the results.
To get see what categories are attached to your post, print the value from the get_the_category function inside a <pre></pre> (which formats the code):
$categories = get_the_category();
echo '<pre>';
var_dump($categories);
echo '</pre>';
This code will print the category name, add a like break and then print the category description.
The var_dump will display the output from the function.
After you understand the output from the function, you can display the categories by using this:
foreach((get_the_category()) as $category){
echo $category->name."<br>";
echo category_description($category);
}
Feel free to ask more question if this do not solve your problem.
Note: Tomatoes are a fruit 😛
Related Posts:
- Customized title tag for each page in pagination?
- Change description on specific WooCommerce product status change
- PHP code to call image Caption, Alternative Text, and Decription?
- HTML tags in bloginfo description
- Move category description below post list in blog
- How can I add an area/option for a custom page description?
- Add Custom Category Description When Empty
- View tag description on page
- New term taxonomy and description in front page. Input’s
- How do I check if a string contains a specific word?
- WordPress “Link has expired” error on updating posts
- WordPress category loop offset possible?
- add_filter to post-gallery and remove all ‘s?
- Guidance with The Loop for CMS
- Run shortcode at certain resolution
- How do I make wordpress comment fields required?
- Using PHP in a Stylesheet (possibly a “.htaccess” problem?)
- Go to / Scroll to Password Field on WordPress Posts After Submit With Message(s)
- Enhanced WordPress Search
- Modify Maximum upload file size text
- WordPress Redirect: Default Password Reset URL [duplicate]
- Wrap First Character after in a tag
- WordPress Site front End and Back End Loading Slowly
- How to Insert Shortcodes into Theme?
- How do I implement a .diff changeset from core.trac.wordpress.org locally?
- How to filter posts by post format “standard” from wp-json api?
- Register JS for block on frontend only
- What does $wpdb->get_row return?
- Why is file_get_contents returning page source?
- Plugin CSS not enqueing
- What is an equivalent of single_cat_title for getting the slug of the category?
- Count the number of custom posts per user
- WordPress Script stops suddenly
- Woocommerce api: create product with images – bad request
- PHP Fatal error: Uncaught Error: Call to undefined function wp_kses_normalize_entities() in new wordpress installation
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Are nonces in WP REST API optional by default?
- getting logged in user info (wp-load.php) from parent directory
- HTML tags not showing in excerpt
- Add .htm extention to a custom taxonomy
- Display most popular posts of category
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- Warning message (re. php) on the blog page
- Get html data with javascript to php array and store to wordpress database
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- How to include custom code on a page that’s set to act as homepage?
- How to upload WP user avatar on woocommerce account page [closed]
- Fixing Deprecated: get_the_author_lastname
- add_filter function concatenate string and locate_template function
- HTTP ERROR 500 after installing child-theme [WordPress] [closed]
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- How to get a list of users who like a current wordpress post [closed]
- ‘pre_user_query’ interfering with user export
- Custom CSV exporter – Cannot modify header information – headers
- Custom post type url Rewrite (conflicting with page url)
- pagination broken – clicking next displays “page not found”
- PHP: How to access db the right way in plugin?
- How to decrease the max file upload size without using php.ini or htaccess?
- populate select options from extra mysql table data
- Custom forms with HTML
- Nav Walker that shows only children and siblings of top level parent menu item
- Add posts to custom table in database instead of wp_posts
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Foreach loop is unexpectedly outputting an extra empty a tag
- What are the advantages/disadvantages of ways to use php template files?
- remove_action from parent theme using child theme functions.php
- Hide Approved status for certain users in users list
- is_user_logged_in returns false when I access certain pages
- wp_signon works local, not on https
- Get WordPress username to customize url
- Delete empty title_tags, find a h1 heading and echo it
- Get posts from year from URL
- HELP: cannot log into wordpress. PHP error
- WordPress is setting from header wrongly in wp_mail
- Add post title as a link parameter
- Search for images that width and height is more than 500
- How do I get object if class is instantiated only like this new classname()
- How to create a php page to collect information from a html page
- Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
- I need help implement a Javascript code into the PHP file
- Passing different content to template parts
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Run insert if no entry otherwise run update with ajax
- Hide cart when empty [closed]
- Overwriting a Shortcode
- Post Title Not showing up
- MySQL database migration to WordPress
- How to check if a value exists in one of two database tables
- Is this WordPress code causing page weirdness? Can’t scroll to bottom
- Search result page – display values from the result’s metaboxes
- How to use multiple 404 Error Pages in WordPress
- Parse error: syntax error, unexpected ‘}’ in
- WordPress add parameters with friendly url structure
- Different behaviour between “include_once” and directly echoing out html code?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- How can add alt tag in following code. Image are showing dynamic in wordpress
- How to pass php array to external js file in WordPress
- check difference between two timestamp in custom plugin
- WordPress Product Page Change Label From ‘Category’ to ‘Artist’