Site logo

Archived topic

Make div all linkable in element

19 replies · Started by William on December 21, 2020

Viewing posts 16–20 of 20

href="https://wordpress-425633-1630880.cloudwaysapps.com/claude-mckay/"

This has to be dynamic.

We can create a shortcode for this:

function dynamic_category_link_function( $atts ) {
    ob_start();

        $page_id = get_queried_object_id();
        $categories = get_the_category( $page_id );
        foreach($categories as $cat){ 
            $cat_ID = $cat->term_id;
            echo get_category_link($cat_ID); 
        }
    
    return ob_get_clean();  
}
add_shortcode( 'dynamic_category_link', 'dynamic_category_link_function' );

And then try changing this:
<a href="https://wordpress-425633-1630880.cloudwaysapps.com/claude-mckay/" rel="tag">

To this:
<a href=[dynamic_category_link] rel="tag">

Ah that's brilliant thank you! Works a treat! Is there a way to make the whole div element clickable?

Yes, that's right. I'll close this then so it can be addressed there.

Thank you. We'll make sure it gets addressed.

This archived topic is closed to new replies.