Ecommerce Shopify WordPress Discussion

How to enable shortcodes for WordPress category titles?

I want to enable shortcodes for category headers on my website. A category page is an archive page displaying items related to the category. On the headers of other pages types shortcodes are processed without problems. I need the shortcodes to display the current year and month in the header. I tried adding this code to functions.php of my theme, but it didn't work: add_filter( 'the_title', 'add_shortcode_to_title' ); function add_shortcode_to_title( $title ){ return do_shortcode($title); } How can I fix this?
The reason why it's not "working" is because the_title filter hook only works with post/page/custom-post-type titles. For archive titles, including category page titles, you want to use the get_the_archive_title filter hook instead, like so for example (untested but it should work, if not please leave a comment): function wp5542_theme_archive_title( $title ) { return do_shortcode( $title ); } add_filter( 'get_the_archive_title', 'wp5542_theme_archive_title' ); (This all assumes that your theme renders category titles using standard WordPress functions.)

January 23, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.