Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Replacing WordPress widget content class

I am trying to change the classes in some of the WordPress widgets. Specifically, I want to add bootstrap classes.

For example, I want to add the "form-control" class to "wp-block-search__input" class

I have tried

function replace_widget($text) {
        $text = str_replace('wp-block-search__inside-wrapper', 'wp-block-search__inside-wrapper input-group', $text);
        $text = str_replace('wp-block-search__input', 'wp-block-search__input form-control', $text);
        $text = str_replace('wp-block-search__button', 'wp-block-search__button btn btn-secondary', $text);
        return $text;
    }
    add_filter('dynamic_sidebar_params', 'replace_widget');

But this and similar attempts do not seem to work.

I have tried a fair few different options instead of "dynamic_sidebar_params" and I am not sure if this is what I am doing wrong.

I am not sure if it is not working because the WordPress blocks are created in JS.

I don't want to do it by adding javascript or jquery to the footer if it can be helped. I would prefer to do it in the backend.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!