• Resolved stanoam

    (@stanoam)


    I looked everywhere, but I have no idea where to remove the “Tag:” from the product tag page title and leave only the actual title. I’d appreciate it if somebody can direct me.
    Thanks in advance.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Do you mean the list of tags on a product page?

    .tagged_as {font-size:0;}
    .tagged_as a {font-size:20px;}

    Thread Starter stanoam

    (@stanoam)

    No, I mean the literal page title. Like on this page – it says “Tag: Allergan”:

    https://medisilk.com/features/allergan/

    I am using the tags to filter the products by Manufacturer and it bugs the hell out of me that the “Tag:” text is attached in front of the actual page title. I mean – it just looks plain bad. Spent over half a day looking for a solution (i.e. the file I need to edit), then gave up and posted here :).

    • This reply was modified 6 years, 4 months ago by stanoam.

    Ah I see.

    Yes – the whole line is in a H1 tag so you can’t use CSS to get rid of it!

    Thread Starter stanoam

    (@stanoam)

    Nope :). I need the exact php file, but after hours of digging, I still haven’t found it. Tried removing the text with jQuery and Javascript, but it doesn’t work for some reason.

    I used to manage a site done on Magento – it had a feature called Template Hints that, when activated, showed what file each element of the site was coming from – brilliant time saver!

    There is this – https://www.ads-software.com/plugins/woocommerce-template-hints/ – but it’s an old plugin so don’t know if it will still work. May be worth a try

    Thread Starter stanoam

    (@stanoam)

    Thank you for the suggestion. Unfortunately, the pluging doesn’t help – it’s probably some function dug deeeeeeeeep inside some file. I did come across this very nifty plugin thought:

    https://www.ads-software.com/plugins/what-the-file/

    Didn’t solve my problem but will definitely be useful in future.

    That looks like it could be useful!

    Thread Starter stanoam

    (@stanoam)

    Alright – problem SOLVED. Went back to the jQuery drawing board, realized I was an idiot and was using element “id” instead of “class”, which is why my script didn’t work previously. Leaving it here for future reference, in case anybody stumbles from google, having the same problem.

    <?php if( is_product_tag() ) { ?>
        <script>
            jQuery(document).ready( function() {
                jQuery('.tax-product_tag .page_title:contains("Tag: ")').each(function(){
                    jQuery(this).text($(this).text().replace('Tag: ',''));
                });
            });
        </script>
    <?php } ?>

    The PHP tags restrict the script to only be executed on product tag pages and the jQuery looks for the ‘Tag: ‘ string in the page title and removes it. Place it in the footer, above the </body> tag. Nice and simple, with the added bonus of not having to worry about it breaking during plugin update.

    Thank you for the suggestions seank123.

    I’m bookmarking this – could be useful for loads of other things too!

    Thread Starter stanoam

    (@stanoam)

    Ok, here is another solution – this one is PHP. Just find the php file that contains the title element – 8 out of 10 times it’s header.php and replace the code within the tags with something similar to this:

    <h1 class="page_title">
    	<?php 
    		if (is_tax()) {
    			echo strip_tags(single_tag_title());
    		}
    		else {
    			echo strip_tags(get_the_title());
    		}
    	?>
    </h1>

    Where the h1 is the title element, “if is_tax” tells WordPress to display the title without “Tag:”, “Category:”, “Brand:” etc. if it is a taxonomy page and the “else” tells it to just display the page title. I ended up using this, instead of the jQuery script, as it took for time to fire up and you could actually see the “Tag:” blink in there for half a sec. I’m sure it’s not the best solution for a PHP savvy person, but it serviceable for my needs, in situations where taxonomy settings are not easily accessible and you have to dig through tens of php files.
    Note it would definitely break during theme update, unless applied to a child theme.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to remove “Tag:” from product tag pages?’ is closed to new replies.