Use:
get_category_link( $category_id );
See:
https://codex.wordpress.org/Function_Reference/get_category_link
In your specific case:
<?php
global $post;
$categories = get_the_category();
foreach ($categories as $category) :
$exclude = get_the_ID();
$posts = get_posts('posts_per_page=4&category='. $category->term_id);
foreach($posts as $post) :
if( $exclude != get_the_ID() ) { ?>
<a href="https://wordpress.stackexchange.com/questions/219954/<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post c-1"> Link to actual post</a>
<?php } endforeach; ?>
<a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>" title="View all" class="btn border"><i class="i-right-double-arrow"></i> View all <?php echo $category->name; ?></a>
<?php endforeach; wp_reset_postdata(); ?>
Related Posts:
- Simple way to style posts of a single category differently in the loop and in single
- loop in single.php of the same category
- Category slug in in loop always the same?
- Get the children of the parent category
- How to check if I’m on the last page of posts?
- Should category.php and The Loop be used if the query needs to be customizable?
- Exclude the category from the WordPress loop
- How do I use the same post slug for different Categories?
- Rewrite rule page url with category
- get_field not displaying my custom field value
- Default WP Gallery – show only galleries of a certain category
- Rearranging posts based on categories
- WP_Query not looking at child category
- Randomise results from a category page?
- Display all posts in category, with specific tag posts at top
- Show div only if post is in specific category
- Create terms when registering taxonomy?
- How to show a category post to a specific registered user
- Display list of Sub-Categories and the posts they contain, within one main Category
- How to create non-unique sub-category slugs?
- Loop with Dynamic Categories
- Rewrite category slug
- How can I create a loop to build slides based on multiple categories using Coda Slider
- Remove child products from woocommerce category page [closed]
- Get a list of commas separated categories inside a loop
- Using same slug name for a page and category
- Add category to custom post type automatically, using category slug
- Categories list loop – add separator every year
- How would you create a “weekly” archive?
- Exclude category by slug for for each loop
- How to exclude categories from recent posts, recent comments & category widgets?
- Listing all posts from current category on page
- Create single.php for specific category by category id
- I use same slug name for category and page
- Divi change project slug based on category
- Removing the number in a category slug
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Display one latest post from multiple categories
- How do I get the total number of categories in a list of search results?
- Plural Category Base Slug On Category Archive Page
- Check if post belongs to any category
- How to get category id in single.php wordpress?
- Return category slug / title from category ID
- How do I display the posts from a custom post type on a category.php page?
- How to group the loop posts in a particular by author?
- Display products for a category, sorted by post_excerpt
- Exclude category from loop not working
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Duplicate Category and Page URL loads Category instead of the Page
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- If newest post of category is newest post in general, skip first post of category
- a-z list, categories and sub categories in loop
- Category slug $_SERVER[‘REQUEST_URI’];
- 403 forbidden on one page only
- Get the name an the description of a link category
- Using a portfolio_category slug in wordpress URL
- in_category() works in single.php but not in page.php?
- Why would in_category only return one post in a specific category?
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- Categories vs. Page Site Organization
- WooCommerce duplicate sub categories and product slugs
- Need to pull parent category and slug – only pulling daughter category
- Displaying multiple loops based off of category
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- Additional featured post on first page
- Show all posts for a specific category/author
- Redirect category to url with /category
- create a page which displays a list of categories title+ short description?
- Enter a variable in the ‘category_name’ parameter
- Second level subcategory
- how to define category loop last class in the third
- Query Posts Exclude Entire Category
- Pagination for category slug returns 404 when page >= 2
- Displaying a full post instead of a slug per category?
- Class active for Archive link – looped out
- Taxonomy name repeating when showing 2 posts from each category
- wordpress sub-category ( lowercase letters + non-latin characters ) = 404
- Display the last post by each category?
- The default code for “posts_nav_link” on category.php isn’t working
- previous/next_post_link in the same sub-category?
- Remove product category placeholder image (Woocomerce)
- Mod_Rewrite to show only last subcategory in URL
- Send to different single pages by category when multiple categories exist
- WooCommerce – How to show specific category first-rest of products-specific category last
- Counter in loop in foreach
- Multiple Loops on category.php with pagination on last loop
- How to exclude the last post from a category(featured for example) from the main loop?
- How to make the link to the category for a post go to corresponding page number in archive?
- Order by category titles
- Get posts from specific taxonomy term
- ajax for filtering posts by category in wordpress loops
- Inside a loop, how to change CSS class based on category name?
- Exclude current post from loop
- How to insert category list into post creation page, and retrieve chosen categories?
- how to get full category path including parent and subcategories
- Categories list loop – add separator every 3 categories [closed]
- Limit get_categories to show each category once
- Automatically redirect a page to a category that share the same slug
- Display single category name in woocommerce loop
- Show Posts from Single Category Not Working