How to style text in header that is from a custom shortcode

Hi there!

I made a custom shortcode that returns the Woocommerce Product Category. I have placed this shortcode inside a custom content element in the header.

The idea is that this header always shows the title of the product category in the header.

This works fine.

However, no matter what I try, i cannot style this text with CSS??? Styling within the header builder doesn work. Targetting directly with CSS doesn work either.

I am probably doing something wrong, but for the life of me, can figure out what.

Help is really appreciate it!

Ok, i just realized that because i am working with a bar with two layers, it might be in the lower layer and changing the z-index fixed it!

Mmmmm,… not fixed yet…

I added a headline element, with the text content

[page_title]bla bla

Only the sample text ‘bla bla’ gets styled??? the text returned by the shortcode is unstyled??

How can i style that too? See the URL provided above for an example how this now works

Hey There,

Thanks for writing in! You cannot style your shortcode because you have coded it incorrectly. I have modified your code and use this instead:

//shortcode for product category title
function myshortcode_title(){
	$current_term = single_term_title("", false);
	return $current_term;
}
add_shortcode( 'page_title', 'myshortcode_title' );

If you need anything else we can help you with, don’t hesitate to open another thread.

Thanks! You guys are the best!

You’re welcome as always!
We’re glad we were able to help you out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.