Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Get post category as a separate string and url

First you have to find the category ID, which can be done easily with the function get_the_category().

To get the slug, use: $catID = get_the_category(); $catSlug = $catID->slug.

To get the link: $catLink = get_category_link($catID).

Related Posts:

  1. How to add category to: ‘wp-admin/post-new.php’?
  2. Display all posts from specific categories on a page
  3. How to show list of posts by author and category?
  4. Divide Loop Into Days & Categories
  5. How to filter posts that belong to a specific category only if that is the only category
  6. Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
  7. Display post category in foreach loop with category link
  8. Child_of not displaying all children posts.. via get_posts
  9. Exclude category from
  10. Pulling in post category and children within category
  11. Listing Specific Categories from Current Post with Depth
  12. How to make the first post in the loop be styled like a “new / featured” post?
  13. How do I stop the loop from repeating in my category template?
  14. get_the_category listing in hierarchial order
  15. why does wordpress ignore the post args?
  16. Change all author links in Blog roll
  17. Showing categories and subcategories with posts
  18. if in category but only with post meta
  19. Display post number by category
  20. The loop starting at a certain ID
  21. WP_Query of Category Not Showing First Post
  22. posts going to 2 pages/categories only show up in 1
  23. Get current taxonomy and display query accordingly
  24. Only the most recent post is showing on my category page (working on localhost, not live site)
  25. Post meta not working
  26. Current post categories and subcatecories outside of the loop
  27. How to distinguish pages created by woocommerce?
  28. Re-order Category Meta-data
  29. How to show category image if no featured image is set?
  30. Display new posts categories in separated divs
  31. List Authors For Current Category
  32. Multiple Post Repeat for Related Post Loop by Category
  33. Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
  34. Show post if in category
  35. Displaying categories items among posts
  36. Make assigning post to a specific category equivalent to assigning it to all categories
  37. Show all posts in category
  38. View post with specific category id and name which I selected in the backend (drop-down option)
  39. Site ‘Categories’: save an admin global setting with post metadata [closed]
  40. WP_Query: Mixing category__in and tag__in together
  41. Start WP Pagination From Number 1 in URL
  42. If in_category not working for multiple single.php pages
  43. Calling Different Custom Post Timestamps in a table
  44. How can I setup a relationship using categories in WordPress?
  45. WordPress Multisite – Create Default Post and New Category On New Site Install
  46. how to show single post in a custom template
  47. Using ajax on editing a category edit page?
  48. Is it possible to paste a link without tags and make it directly a link in a post?
  49. Related posts by category not working right
  50. How to list recent posts in a wp nav menu?
  51. Set Default Category to Username
  52. Disable sticky option for specific categories
  53. Dynamic dependent Dropdown lists for categories, sub-categories and posts
  54. How to add tags (custom taxonomy) to post class css?
  55. How can I hide tags on a child-category page, if that tag has not been used?
  56. date issue with category post retrival
  57. Cannot retrieve a custom RSS field from posts
  58. List authors with the last post title and order by last post date
  59. How to exclude visited posts from loop
  60. How to make multiple sections in home pulling posts category wise?
  61. Use two different post_per_page limits with infinite scroll
  62. How to display two blog categories as separate sections on one page?
  63. Saving custom fields to a custom taxonomy
  64. wp_query random post
  65. How to Mysql select a list of posts with meta_values AND all relevant categories?
  66. “Right Way” to make custom Loop respect reading settings inside admin panel?
  67. How to setup a query to output posts by groups of five?
  68. Only display sticky post or latest post in custom loop
  69. Display post category in foreach loop
  70. Single.php – Get Current Parent Category
  71. How to order posts in an arbitrary order?
  72. How to automate featured posts number? [duplicate]
  73. Is it possible to add/tick a category to a post when it is created?
  74. Excluding posts not working
  75. How many posts does the loop return?
  76. Display Posts on Custom Page
  77. How to make a sum of all posts displayed in a loop
  78. Possible to alternate between two loops
  79. Exclude current custom post on single post
  80. Hide posts belongs to few categories in homepage
  81. Wrong post title displayed from loop
  82. Get Value of Post before
  83. post category in wp_insert_post
  84. Multiple Loops Breaking Pages
  85. add to end of post in the loop with plugin
  86. Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
  87. Recent posts per category loop?
  88. First x post with another template then the others
  89. How to get subcategories from category slug?
  90. Remove current category from post but display all others
  91. Loop doesn’t show title of second post and posts thereafter
  92. How show categories in admin and get that selected to show posts in index
  93. Customize rel=canonical tag for single blog post
  94. How to I retrieve the ID from the Posts page?
  95. How to save meta checkbox WordPress
  96. Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
  97. Second get_permalink inside loop points to wrong URL
  98. Change default category when I publish a post
  99. Get the amount of posts on a current page
  100. Loop parent terms {display posts} AND loop child terms {display posts}
Categories posts Tags categories, loop, post-meta, posts
update_post_meta not working?
Woocommerce products per page dropdown

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress