Jump to content

Archived

This topic is now archived and is closed to further replies.

Plev

Add custom class to section

Recommended Posts

Plev

Hello, I have simple question, is it possible to add somehow custom class to let´s say custom section (for example clone of whichever core section in the child theme)?

For example, I need to create my section which will be based on core section textBox and I would like to add some class to the wrapping HTML tag <section>, is it possible, if yes how can i achieve that?

 

Thx in advance!!!

Share this post


Link to post
Share on other sites
Danny

Hi,

 

All sections have an option called Custom Styling Classes field, if you enter a class name into this field then add custom CSS, any section that has that class will incorporate that styling.

 

For example, let's say you add the following custom CSS:

 

.example-class {

  background-color: red;

  padding: 100px 0;

  color: white;

}

 

Then you add the following to your cloned TextBox sections styling classes field:

 

example-class

 

That TextBox or any section you add this class to, will have that styling.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Plev

Yes that is an option, but i would like to set the class according some options inside of the section for example let's say i have option taxonomy and inside of section i would like to detect what taxonomy was selected (that is not a problem) and accroding that add my custom class to the section (is that possible, i thing should be but, so far i havent figured it out), add class to any other dom element inside of the section (which is inside of the function section_template is not a problem, but i am looking for a solution how to add a class to that section tag which is generated by dms) thank you for your first reaction, looking for next one, thx  

Share this post


Link to post
Share on other sites
Danny

I apologise, but I am not sure what you're trying to achieve ?


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Plev

ok, well it looks like i've figured it out, if somebody is looking for something similar here is the code:

 

function before_section_template( $location = '' ) {
 
                $this->wrapper_classes[] = 'custom-class';
                
}
 
but i would really appreciate if you can explain me role of the attribude location in the function before_section_template, thx 

Share this post


Link to post
Share on other sites
Plev

ok, better solution of the code above is to add your custom class to existing wrapper_classes['user_classes'] and avoid strange behavior with more instances of the section on one page

 

$this->wrapper_classes['user_classes'] = 'custom-class';

Share this post


Link to post
Share on other sites
Danny

Thanks for sharing.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please? 

×