Archived topic
Make div all linkable in element
19 replies · Started by William on December 21, 2020
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?
Sorry for the delay in response.
I believe this particular question is directly related to one of your open topics here?
https://generatepress.com/forums/topic/custom-field-color-to-change-element-background/page/3/#post-1599292
It may be best if we answer it there. We'll make sure it gets addressed.
Yes, that's right. I'll close this then so it can be addressed there.
Thank you. We'll make sure it gets addressed.