-
Hello,
I can’t find a way to insert rel “nofollow” and “sponsored” to a dynamic title that easily that link to a dynamic custom meta.
For the image block and button block it’s quite easy, it’s there, visible and straight away.
For the heading block, I can’t find it.
Thanks for your help,
Samuel -
George
Hi Samuel,
The Headline/Text block doesn’t currently expose a
relattribute field in the UI when using a dynamic link, unlike the Image and Button blocks. You can work around this using therender_blockfilter with a custom class applied to the block:add_filter( 'render_block', function( $block_content, $block ) { if ( ! is_admin() && ! empty( $block['attrs']['className'] ) ) { $classes = explode( ' ', $block['attrs']['className'] ); $rel = []; if ( in_array( 'cu-add-nofollow', $classes ) ) { $rel[] = 'nofollow'; } if ( in_array( 'cu-add-sponsored', $classes ) ) { $rel[] = 'sponsored'; } if ( ! empty( $rel ) ) { $block_content = str_replace( '<a', '<a rel="' . implode( ' ', $rel ) . '"', $block_content ); } } return $block_content; }, 10, 2 );Add
cu-add-nofollowand/orcu-add-sponsoredas additional CSS classes on the Text block. The filter will inject the appropriate rel attribute on the rendered anchor. -
Ok, thanks for your help !
This would be a good feature to add then, to make the whole dynamic process transparent in all ways.
-
George
Hello,
Thank you, I have raised this as a feature request. Meanwhile, you can also suggest this in the feedback board.
- You must be logged in to reply to this topic.