Btw, i tried to make it work using CSS but for some reason the title is not displayed (i guess PHP code doesn’t work in CSS).
a.tag-cloud-link::before {
content: "<?php echo get_the_title(post->$ID); ?>";
}
Any ideas? Is there any function I could use to achieve this?
Plugin Author
WPKube
(@wpkube)
Hi,
Yeah, PHP code does not work inside of CSS code unless that CSS code is generated by PHP.
So you could use the Code Snippets plugin and create a PHP code that generates CSS.
The code would be:
add_action( 'wp_head', function () { ?>
<style>
a.tag-cloud-link::before {
content: "<?php the_title(); ?> ";
}
</style>
<?php } );
Or you could of course just put that in the functions.php file of the theme, but keep in mind that if you are not using a custom theme that code would be overwritten on update. So, you should use a child theme. But if you aren’t familiar with all that, go with the plugin I mentioned.