You can use below code to append the string:
<?php
$category = get_the_category();
$related_blog .= '<div><a href="'. get_category_link($category[0]->cat_ID). '">'. $category[0]->cat_name.' </a></div>';
?>
Related Posts:
- exclude multiple terms using get_terms() function
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Allow authors to post only in categories they create in WordPress
- Add custom field to attachments in a specific category
- How to Populate the list of custom post type categories
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- Check if Product is in a Specific Category in Functions.php
- Woocommerce – remove product from category
- get current product name in functions.php
- get post based on category chosen in drop down – The ajax method
- Swapping wp_dropdown_categories function with wp_category_checklist
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to pick the default selected value in wordpress dropdown?
- Get page that displays all children of taxonomy parent
- Dilemma of Populating all the categories in a drop down list
- Edit the_category (); for a hierarchical display
- Displaying posts based on category
- How to get the last category name of a child category?
- How to get current post category details inside “loop”?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Dropdown category field inside repeatable metabox
- Display Visual Composer shortcode if a post belongs in specific categories
- Get parent category name when only child category is applied to a product
- How to move a post from one category to another
- Notice: Undefined variable
- Hide a specific category title from displaying on site
- Populate Posts based on category selected using AJAX that means without page refresh
- All categories options or All categories not Populating
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- PHP get_category() function redeclared
- Get category id for a custom category and display it in a class
- Trying to see if page is category or single and displaying title with appropriate heading tag
- Displaying categories
- How to insert the first letter in uppercase [closed]
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Exclude a category ID from the following function
- Hide old attachments from wp media library
- PHP – redirect https to http and www to non-www
- How to overwrite youtube embed?
- Understanding WordPress child theme custom JS loading
- Problem with ACF shortcode with Repeater Field in WordPress? [closed]
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- Insert After Second Paragraph Without Tag?
- User Defined order on get_categories?
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Using wp_get_image_editor in a standalone script
- page template for attachement page?
- PHP Deprecated: WP_RSSjb has a deprecated constructor
- Removing unneccessary p-tags (Not every p)
- Set WordPress Default Template
- Showing content from one page on another
- How to insert a single row to WP database table?
- Get date numerical and separate?
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- How to check if a meta value has already been assigned to any user?
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- How to call plugin function per site in a multisite?
- Ajax load more button for comments wordpress
- Unique icons next to each WordPress menu item
- Update user profile information from functions.php
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How to set the WordPress logo programmatically with PHP
- Function works everywhere, how to keep it to execute when creating a new post
- Function won’t run onclick using Ajax
- Add login hyperlink to secondary navigation menu
- List all blogs, but exclude the main site
- Use get() method to grab all categories and output inside another method
- Reading settings in the home page precisely home.php
- Calling function in loop causes repeat data
- Is there a hack for using is_page() within the function.php file?
- Add a select-option to the default widgets
- Programmatically revert to backup .htaccess a possibility?
- WP-Bakery – Add custom colors to buttons with template colors
- WordPress User Meta value variable into Google Gauge Chart
- Show all people who commented on all posts by an author
- Custom global variable not working in function
- Embed video from streamtape using direct link
- Is there a PHP function that will return the block ID generated by WordPress?
- get_the_author_meta( ‘ID’ ) just return 1
- Site title not showing. Please help me
- Check if post visited first time
- Store custom field’s multiple values in one user meta key
- Need to Echo A Url path to show on a wordpress page
- Theme editing “post thumbnail” help
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- How to list categories by page id in wordpress
- AJAX Returning Way Too Many Posts
- Where can I find the declaration of `$_wp_theme_features`?
- redirect 301 with special character like WIX site “#!”
- How I can add div to menu?
- How to print redirected query string variables to the page?
- Admin-area broken through weird issues
- How to get category pages to look like a certain archive page?
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- Select area and checkbox data is not saving?
- How to modify this function to exclude also the post belonging to a specific category?
- Suppress errors when using global function