Here we’ll use the function – get_categories()
to grab all the available categories and store it as array, Then we’ll loop through the array to display the list. Within the foreach loop we did a conditional check that is to determine if category is parent if so print it.
<?php
$categories = get_categories();
echo 'We have ';
foreach($categories as $category)
{
//to check if category is parent
if ($category->parent==0)
{
echo $category->count . ' ';
echo '<a href="' . get_category_link( $category->term_id ) . '">'. $category->name . '</a> , ';
}
}
?>
Related Posts:
- How to display by default only published posts/pages in the admin area?
- Is there an if statement that can determine if a post in the loop is the last post?
- Access post from post id in URL
- WP_Query: Why is sticky post not first item in loop?
- How to mark articles as read?
- Is there a way to disable the sticky posts feature?
- How to remove Nextpage tag inside posts text depending of utm_campaign
- using slug instead of ID in admin edit post url
- Can I load posts via Ajax?
- WooCommerce – Create Products Programatically [closed]
- Code to auto expire posts after 30 days
- Search not working with title and content
- Filter posts by author and category simultaneously
- All WordPress scheduled posts are being published immediately
- WordPress Delete hook with wp_delete_post function?
- How to use alternate post layout at key points in post loop?
- Undelete post (untrash)?
- Changing publish date does not update post order
- Hide Post comments when displayed via WP_Query
- Show all post titles
- Posts are not showing up on particular category
- Different style for most recent article
- Differentiate between posts and pages in search results
- WordPress Theory Lesson – Image Columns within posts with alignment?
- Uppercase first sentence in every post
- How to Orderby Comments by post title?
- If modified on same day, show only time
- How is a gallery associated with some post in database?
- Page Navigation for list of post
- Extracting post categories
- Exclude post_meta from Rest API Endpoint
- impreza portfolio display/view blank page
- How to verify wp user password by sql query in wp? [closed]
- Automatically add custom fields value to wordpress post
- How to use format post in a pertinent way
- Meta value does not save for scheduled posts
- Loading post with Ajax
- How to create media library for each user?
- My wordpress based site is publishing the same post twice
- When creating a post how do you select the format?
- How can I post exact same post but with a few things changed? (with some sort of Automation)
- Loop doesn’t show title of second post and posts thereafter
- Which PHP files should I edit for changing POSTS list and view pages?
- How to add add more properties to WP_Post object in search results loop
- How to get current post ID in functions.php
- How to show all posts by author on buddypress profile with navigation
- Get URL from all images in a post
- Change the default blog post post attribute template name from “default template” to something else
- single post showing blank page in custom template
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Display post by click on the link
- How to call posts under a specific category on static front page?
- Get total post from an author
- Image on rss feed on post
- Limiting post list by taxonomy
- select post preview image from nextgen gallery
- WP_Query articles order by offset in collumns
- sort posts by getPostViews in functions.php
- Making a wordpress page print friendly
- Will multiple category descriptions effect my search engine optimization?
- Different post views for different category views
- “Home” Page now only displaying the single latest post
- How to select a category automatically based on a word in WordPress post title?
- WordPress React re-rendering to many times
- Post feature image after post title for single post
- How to get unmodified post content?
- I have inserted a post’s content in homepage.php by the post-id. The font isn’t matching with the theme. How do I change font of this content?
- Random post_id at wp_insert_post
- Odd hyphen added at end of blog post
- load post data into mysql
- filter posts based on menu_order
- How to delete all posts with dead image urls?
- Get a list of categories that are related to posts
- How can change header text in post careate/edit form
- wp query custom orderby not custom field
- Update all images url imported from HTML pages
- numberposts not working
- How to modify specific parts of a post content in WordPress
- How do I allow my post to update it’s date every week
- How to change the publishing date of each posts?
- Include post on external custom site
- WP Load post with ajax and apply isotope
- Count how many posts a user has viewed
- Use a custom post URL that is outside the blog root directory
- Display the current post author and his url in the post header
- How to change link with broken link?
- How to change date_format in entry-info
- Only display price when value exist
- Output posts with same name as tags?
- Related posts by searching post tags of single post as terms
- How to make a posts page display only intros of posts?
- custom sort posts in archive/taxanomy page
- How remove “recent comments” title without modifying code? [closed]
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- remove description in colum title post
- Show some texts in posts belonging to Specific category
- Read more opens attachment
- How to show video from post on the all posts page?
- Show a page counter for pagination
- WP_Query post_tilte search in posts table