- This topic has 11 replies, 2 voices, and was last updated 3 years, 11 months ago by
Leo.
-
AuthorPosts
-
June 12, 2019 at 7:31 am #927129
Sam
Hi, I am trying to add buttons using your article: https://docs.generatepress.com/article/adding-buttons/
However, when I add the tag to the product category description (woocommerce) when I save the changes it strips out the class (leaving something like: Button), meaning I cannot style the button. do you have any ideas on how I can overcome this? If you look at our current theme (which we will be moving from) you can see the buttons above the description text. I do not want to add a header element as the buttons would be different for each category so want to be able to manage them for each category.
Many thanks
SamJune 12, 2019 at 9:04 am #927217Leo
StaffCustomer SupportHi there,
Not sure if I fully understand.
If the HTML is getting stripped, it’s likely that there are some syntax errors.
If you want to add specific style buttons, this should be the HTML:
<a class="button style-1" href="https://google.com">Button to Google</a> <a class="button style-2" href="https://google.com">Button to Google</a>
Then you CSS would be this:
a.button.style-1 { color: #000; background-color: #fff; }
Adding CSS: https://docs.generatepress.com/article/adding-css/
Let me know ๐
June 12, 2019 at 9:15 am #927229Sam
Hi Leo, sorry if I made it sound confusing.
If I paste exactly the button code snippet into the description of a product category:
Then click “update” it strips out the class and the result is as below after the page reloads:
Does that make sense?
June 12, 2019 at 9:18 am #927231Leo
StaffCustomer SupportI tried the exact same code and it’s working.
Tough to tell without seeing the issue live but it could be a caching error.
PS please highlight your code and click the
code
button in the editor.June 12, 2019 at 9:31 am #927243Sam
Ah sorry I missed that…
See below
<a class="button style-1" href="https://google.com">Button to Google</a>
becomes
<a href="https://google.com">Button to Google</a>
I have no caching activated.
June 12, 2019 at 9:38 am #927251Leo
StaffCustomer SupportSorry I’m not sure why it isn’t working for you.
That is just plain HTML in WordPress editor and GP doesn’t have a way to make it not to work.
Can you make sure you are using the text editor?
Here is a little clip showing that it works:
https://www.screencast.com/t/4lgOzZC4z5June 12, 2019 at 9:53 am #927268Sam
Yeah it’s really odd.
Yes I am, see here: https://www.dropbox.com/s/j74q0h1umssl4gp/buttons.mov?dl=0
June 12, 2019 at 9:58 am #927276Leo
StaffCustomer SupportHmm that’s the category description field which doesn’t allow HTML as far as I understand.
Does the code work on a normal page text editor like I did?
June 12, 2019 at 10:05 am #927289Sam
Hi Leo, what is odd is on my live site, it has a Tiny MCE editor…
Now I am very confused. Would that editor have been added by the theme I am using on the live site?
https://www.dropbox.com/s/vz7d6t79z7ejd9r/Screenshot%202019-06-12%20at%2019.03.15.png?dl=0
June 12, 2019 at 10:08 am #927293Leo
StaffCustomer SupportMaybe you are using a plugin to allow it.
Google “category description wordpress html” and you should see multiple articles mentioned that it is not allowed by default.
I assume the same code works on a static page text editor?
June 13, 2019 at 12:17 am #927915Sam
You know it’s strange, I never remember having to do anything on our current set up, so maybe it is to with our theme or something. I guess I will find out when we migrate to GP. I did as you suggest and the code from the WC website worked:
/** * Allow HTML in term (category, tag) descriptions */ foreach ( array( 'pre_term_description' ) as $filter ) { remove_filter( $filter, 'wp_filter_kses' ); } foreach ( array( 'term_description' ) as $filter ) { remove_filter( $filter, 'wp_kses_data' ); }
thanks for the help.
June 13, 2019 at 8:30 am #928574Leo
StaffCustomer SupportAwesome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.