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?
- 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
- get_field not displaying my custom field value
- Show div only if post is in specific category
- How to show a category post to a specific registered user
- 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
- Categories list loop – add separator every year
- How would you create a “weekly” archive?
- How to exclude categories from recent posts, recent comments & category widgets?
- Listing all posts from current category on page
- Divi change project slug based on category
- How to get category id in single.php wordpress?
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Duplicate Category and Page URL loads Category instead of the Page
- 403 forbidden on one page only
- Using a portfolio_category slug in wordpress URL
- Categories vs. Page Site Organization
- Pagination for category slug returns 404 when page >= 2
- Class active for Archive link – looped out
- Taxonomy name repeating when showing 2 posts from each category
- Display the last post by each category?
- Mod_Rewrite to show only last subcategory in URL
- Counter in loop in foreach
- How to exclude the last post from a category(featured for example) from the main loop?
- 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?
- Limit get_categories to show each category once
- Automatically redirect a page to a category that share the same slug
- Is there a reason I cannot get the current category in a loop?
- Category archive is displaying all posts rather than the specific category
- Use the category name instead of category slug in permalinks
- new WP_Query all post in a category inside the loop
- How to add orderby parameter for sorting on category.php
- category__not_in and id values from variable
- How to loop custom post_type from (a) specific category(ies)?
- How to display the parent category if only the child category has been chosen
- Category tags with comma’s
- Display posts of certain categories to specific user roles
- Allow user to select categories that will display in post loop
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- Getting the Most Recent Posts from Multiple Categories
- Display subcategories in dropdown
- Display category title and three latest post inside the category
- More efficient way to list posts by category [duplicate]
- How to get nav to show current_page_parent class when on regular post (not blog), differentiated by category
- Category nicename inside loop in wordpress
- filter a loop base on specific category
- Ordering categories by slug vs. name
- Limit Loop to One Category
- Filter Category Loop Dynamically
- Editing Loop So It Targets Specific Tags?
- Conditional category query breaking?
- Problem: retrieving parent category’s first post
- Posts made to category don’t show up (do show up on frontpage)
- Category name for all posts getting assigned to a single random post
- Category post count is not correct
- Display all categories but only if they have posts in them that have a specific tag assigned
- Include last post date in get_categories loop
- Different post slug based on archive
- How to remove category name for only one category?
- How to get specific (grand parent) category of current post?
- Custom Loop with certain number of one category
- how tho change number of posts in loop from specific categories
- Template category.php with page (no posts)
- error in specific category loop
- Please tell how to stop the category from showing up on posts
- Hide a category/posts from the homepage in wp
- Get category from slug list
- Display Some text in some specific category not all category
- When category name and title are the same … WP will select archive.php instead of single.php
- Assign a class to first element in category in loop
- Trying to display all posts in a category
- Hide category name using mod_rewrite
- Display Taxonomies in loop with template args
- Code to display category-specific single.php is overriding normal single.php, too
- How to exclude a specific categogy from a custom page template
- Display Referring Category on single post?
- woocommerce – products by category slug? [closed]
- How to get multiple loop in category.php, my scripts becomes madness
- Modify / Rewrite single template url structure
- Custom Category Page Not Working [duplicate]
- My Query is getting the wrong data
- How do i add custom post types to this query?
- How do I get a single page navigation depending on the previous page?
- Custom loop by url
- Custom WordPress category page showing all posts rather than the specified category
- Show all posts in category
- Do not show all post from all categories, just show posts from category in current loop
- IF have_posts contains posts from a certain category
- Echo Category In Loop