• Hello,

    I would like to display the page title name before each tag (i.e. page title tag 1, page title tag 2, page title tag 3, etc)

    I tried to find the code that outputs the tag name so I can customize it but no luck so far.

    Can you please help?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alexwebermedia

    (@alexwebermedia)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Page Title before Tags?’ is closed to new replies.