If you can add your code, It may help for everyone. By reading you question. By default normally that get_category_link
is have to work. Just use global $post
before your loop
. If is not work. What you have to do is.
-
Grab the category id using your
@category
variable. (you can useprint_r($category);
orvar_dump($category);
after your code$category = get_the_category($post->post_ID);
) -
Then use
get_category_link(pass your grabbed category id)
I’m sure it will work.
For more info. Read this CODEX
Related Posts:
- Custom Category widget
- Get images by category
- WordPress – List Sub Categories and Sub-Sub Categories, With Posts
- Get Posts Under Custom Taxonomy
- How do I get posts by multiple post ID’s?
- setup_postdata() does not seem to be working?
- Regenerate Slugs From Title of Posts
- Why get_posts are only showing five posts (retrieved by assigning a category to them?
- WordPress get_posts by category
- Alternative to get_posts() due to multithreading cache crash
- exclude category from get_posts?
- How to get current post ID in quick edit callback
- How to restore deleted pages/posts?
- get posts based on meta value of the author
- date_query not returning some posts in date range
- How do you get posts by meta_query using the JSON API plugin?
- Why favour the standard WP loop over iterating over (new WP_Query())->get_posts()?
- Query posts ordering by title, but ignore ” and special characters
- get_posts not honoring post_status
- Query only Posts from Both of Two Category?
- get_posts only children from certain parents
- get_posts cannot grab from specific category
- Filtering custom post type query
- get_posts from post x(offset=>x) to end
- With get_posts(), how can I put a category as a variable
- Serialized array, grab specific posts with meta_key/meta_value[0]->is_featured
- How do I combine these 2 queries
- Increase the page size of the WordPress REST API
- How to show more than 5 posts?
- Cache Get_posts
- get_posts() returns all posts rather than the ones specified with ‘post_author’ =>
- Query random post from different categories
- get_posts() excluding all children of a specific post/page
- `get_posts()` ignore my custom post
- excluding current post from get_posts
- How to query posts to include specific pages of one post type, and all pages of another post type?
- Only retrieve posts where post_excerpt has been filled out
- Can I use numberposts=-1 and offset together when using get_posts()?
- Ordering posts in get_posts
- I don’t arrive to do order_by title when i have a conditionnal year in a request
- Meta query: get posts with value in a multidimensional array
- Get posts inside Get terms problem
- get_posts and multiple categories
- Trying to only display 1 category using get_posts
- Ho to add get_relative_date and post_except to this get_latest_post query?
- Get Posts Under Custom Taxonomy
- How to get the post content from a category on my homepage
- get_posts() not working in functions.php
- Get posts from specific taxonomy term
- Getting only a specific post type with get_post?
- Display post details by post ID
- What is the p parameter in a get_posts() parameter array?
- Memory issue with get_posts( ) function
- get_posts() using an array of post ids [closed]
- List all posts in a category with query_post() function
- How can I show the author’s latest post with title?
- get the post_date of ID
- Hooking to walker_nav_menu_start_el to insert list of subpages
- Get posts in between specific ID’s
- Don’t submit post if post title exists
- How to pull a list of posts in a category while exluding posts in subcategories of the category
- Hide gravity forms
- Why would get_posts be ignoring posts with 2-digit ids?
- Not able to get random post
- Order custom post type by custom field (created by PODS) via PHP
- How to Link to Most Recent Custom Post of Same Term
- get_posts returns all posts
- Override Blog pages show at most with get_posts
- WordPress Random post (last 3 days posts)
- ‘child_of’ in get_posts not working
- How to get post with slug and exclude categories
- How to get posts by category and by choosing a taxonomy term?
- Fetching All Posts (200+) in a Category – Performance Issues?
- How to properly use Categories with Custom Post Types
- List all pages including archive
- How do I get only a certain number of images from a post (minus the featured image)?
- Yet another get_posts() in explicitly defined order problem
- List random posts on single page in the current category
- Divide the list into two columns (get_posts)
- get all categories’ latest post in one query
- Load the last post of a category
- WordPress echoing content in seemingly random place
- How to add content above footer in posts from specific category
- How to use get_posts to filter against a single post id?
- Custom post type data not displaying If I select the category from the dropdonw
- Why set cookie from URL parameter doesnt work all the time?
- Is there a way to extract a single post better than using get_posts()?
- Array merging multiple get_posts throwing Undefined offset error
- get_posts – check if custom field has content?
- Get posts base on category ratio of more then two categories
- Why does ‘meta_key’ return an empty array in get_pages
- How to Retrieve Post ID of another page
- Show last post from multiple categories using wp_list_categories
- not empty categories don’t show in menu [closed]
- Sorting posts by specific order
- How to create a custom loop ordered by Categories on a Page Template?
- how to ask if in two categorys inside if
- wordpress show category link instead of post link [closed]
- Add Category names to post lists of custom post type
- filter on get_posts efficiently