Why can't I link my custom post to the same category archive page?

I want to link my custom post to category archive page. The same category that my post is. I have a query loop with my custom posts and I inserted a button that is suppose to link to: {post_terms_category}. When i click on it I go to an error page that looks like this:

<a%20href=“https:/“mysite”/category/azija/vietnam/”>Vietnam

There already is a /category/azija/vietnam/ page that works perfectly and it’s an archive page that displays normal WP posts.

What am I doing wrong here? This has been driving me crazy for the past week now.

What’s even weirder the link actually takes me to the right page if i put {post_terms_category} as a link on “Post title”. But if I put the same {post_terms_category} as a link on button it takes me to error page… is this a bug?

Hi @Anze did you ever get this working? Having the same issue.

Having the same issue.

Hi guys,
{post_terms_category} gets outputted as a link by default. If you use it inside a link field, you’ll get a link inside a link, which is not allowed and cannot work.

However, there are two ways to remove the links, as described in the academy:

  1. Use the :plain filter: {post_terms_category:plain}
  2. Use the bricks/dynamic_data/post_terms_links Filter: bricks/dynamic_data/post_terms_links – Bricks Academy

Best regards,
timmse

Thanks @timmse

I ended up using the bricks filter to disable the link for a specific taxonomy, and using: {post_terms_archiveName}.

It worked, but for some reason archive categories with spaces e.g web design, the url wouldn’t append a dash (-) in place of the space, instead it would add %20, resulting in a 404.
So it would should be mywebsite.com is available for purchase - Sedo.com
instead it’s mywebsite.com is available for purchase - Sedo.com

I couldn’t figure it out so I just added a re-direct on the broken url to the correct url.

For anyone that had this issue I ended up using a code block instead of a button using dynamic content , not sure if it’ll work in your use case but here it is:

<?php
function get_single_post_category_link() {
    $terms = get_the_terms(get_the_ID(), 'YOUR_TAXONOMY'); 
    
    if (!empty($terms)) {

        $term = $terms[0];
        

        $term_id = $term->term_id;
        

        $category_link = get_term_link($term_id, 'YOUR_TAXONOMY');
        

        return $category_link;
    }
    
    return false;
}
?>

<a href="<?php echo esc_url(get_single_post_category_link()); ?>" class="YOUR_BUTTON_CLASSES">View More</a>

@mibr @Anze