SOLVED: How to unlink the URL from a custom taxonomy?

Hi everyone, is there any way we can unlink the URL from a custom taxonomy for dynamic data?
Like example: {post_terms_job_locations:unlink}

Basically, I trying NOT to have the person click on the dynamic data URL that was auto-inputted from the custom taxonomy that was made. Don’t know how to deactivate that taxonomy URL.

2 Likes

Wondering this as well

Hi Scarlett,
since Bricks 1.4beta you can use and echo custom PHP functions.

Place this function inside of a code element on the same page where you’re querying your posts (with the posts element or a custom loop). Replace ‘custom_taxonomies’ with your custom taxonomy slug. Alternatively, you can place it in functions.php if you’re using a child theme.

<?php
    function post_taxonomy_names_array( $tax_name = 'custom_taxonomies' ) { 
        $terms = wp_get_post_terms( get_the_ID(), $tax_name, array( "fields" => "names" ) );
        if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
            $term_array = array();

            foreach ( $terms as $term ) {
                $term_array[] = $term;
            }
     
            return $term_array;
        }
        return '';
    }
?>

Then, inside of your posts element or your custom loop, call and echo the function:

{echo:post_taxonomy_names_array}

Best regards,
timmse

2 Likes

Option 2
You can disable the pointer-events for the specific field.

Replace the field id with your specific field id and you’re done :slight_smile:

.dynamic[data-field-id="puldok"] a {
  pointer-events: none;
}

This way, the link stays as it is and can be followed by search engines, but is not clickable for the user.

2 Likes

Hey, thanks for the reply. Ya, disabling pointer-events does work but don’t want the search engines to find this link. :frowning:

Oh well, I will stick with my alternate option for now, which I created a ACF to have a label name the same as the taxonomy name and the user chooses from there.

Hello all, it’s now 1.7 and I’m dealing with this right now, and the Bricks filter function does nothing to fix the link-wrapping of taxonomy queries, so it’s a useless/deprecated documentation as far as I can tell. Can someone please suggest a real workaround to this? Bricks is cool and all, but I also feel like I need to jump through 5 hoops every time I want to query anything with anything more than “1 level deep” to it.

@timmse does Bricks plan to either (a) fix this issue in the builder, or (b) provide code that works in snippets?

The code from timmse worked for me, with a minor adjustment to output as a list.

function my_tags_list( $tax_name = 'my-tags' ) { 
    $terms = wp_get_post_terms( get_the_ID(), $tax_name, array( "fields" => "names" ) );
        if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
            $out = "<ul>";
            foreach ( $terms as $term ) {
                $out .= "<li>".$term."</li>";
            }
            $out .= "</ul>";
            return $out;
        }
        return '';
    }

Then in the bricks template > text > content:
{echo:bw_proj_service_tags}

1 Like

You can just use {post_terms_job_locations:plain} - that’s worked for me :slight_smile:

4 Likes