ThemeShaper Forums » Thematic

[closed]

Editing widgets-extensions.php not working

(11 posts)
  • Started 2 years ago by drewdavid
  • Latest reply from helgatheviking
  • This topic is resolved
  1. Hi I am working on a child theme. I created a folder named "extensions" in the "library" folder as per the parent theme.

    Then I edited the form length (shortened it).

    However, no change! What else do I need to know? Could anyone point me in the right direction?

    Thanks :)

    Posted 2 years ago #
  2. i don't think WP overrides the included folders automatically the way that it preferentially uses a template (like category.php etc) from the child theme before it looks for the same in the parent theme. but why would you do that? you can change everything in that folder via hooks and filters from your functions.php. what are you trying to do?

    here's a post that should get you started w/ hooks and filters
    http://forums.themeshaper.com/topic/need-help-understanding-actions-vs-filters-and-changing-post-meta-and-utility#post-22638

    Posted 2 years ago #
  3. Hi thanks for replying.

    When I copy functions.php into my child theme it breaks the theme with this error message:

    Fatal error: Cannot redeclare thematic_remove_generators() (previously declared in /home/content/x/r/o/xroox/html/24hrknight/wp-content/themes/tuxedo/functions.php:134) in /home/content/x/r/o/xroox/html/24hrknight/wp-content/themes/thematic/functions.php on line 134

    Also, I don't see anything in functions.php pertaining to the search form...

    I think I need a bit more assistance yet.

    Posted 2 years ago #
  4. you can't straight up copy b/c then you will have functions named the same thing. as your error indicates. please read the explanation of hooks and filters i linked you too and then let me know what you are actually trying to do so i can offer more specific help.

    Posted 2 years ago #
  5. I do notice an instruction to load the widgets-extensions.php file in functions.php!

    // Load custom Widgets
    require_once(THEMELIB . '/extensions/widgets-extensions.php');

    However I'm still left with the problem of having functions.php in my child theme (see above).

    Thanks :)

    Posted 2 years ago #
  6. Hi Helga,

    I am just trying to shorten the length of the search form from "32" to something like "22".

    It works find when I edit widgets-extensions.php in the parent theme. But of course that kind of defeats the purpose of using a child theme! :)

    BTW I read your post, but frankly I don't see how it applies to something like this (at all). Maybe you could enlighten me?

    Posted 2 years ago #
  7. my post doesn't discuss filtering the length of the search widget specifically. instead i tried to explain filters in general, b/c the process is the same, every, single time. once you get it you won't have to ask, how do i filter this? how do i filter that? b/c you will know how to simply filter. it took me a long time to get my head around it which is why i make a point to try to explain it to people.

    so you want to change the search form length.... the first function in widget-extensions.php is thematic_search_form() and the very first line of said function is

    $search_form_length = apply_filters('thematic_search_form_length', '32');

    in my primer on filters i explained that apply_filters is your signal that you can filter that value, and that thematic_search_form_length is the filter's name.

    then i go on to explain how to set up filter in order to change a variable. which adapted to your specific example should be:

    function kia_search_length(){
       return "22";
    }
    add_filter('thematic_search_form_length','kia_search_length');

    short, sweet, elegant. that is how you filter anything.... take a value in, (not in this case since we don't need it), change it, pass it back.

    hope that makes sense

    Posted 2 years ago #
  8. Hi,

    Thanks it makes some sense now yes.

    First question, where do I place this filter in my child theme? What file does it live in?

    Second, was "kia" an arbitrary name given to the filter, or does it mean something?

    Posted 2 years ago #
  9. all function/filter changes to the parent theme happen in your child's functions.php. at least until you get so many that you need to start organizing them into separate files.

    you can name your function anything you'd like as long as the function name matches the name of the function being added in add_filter. you should preface it w/ something to avoid "namespace collision" which is what you saw before of 2 functions having the same name.

    kia just stands for "kathy is awesome" which if i ever finished my damned portfolio would be my brand name, but you could have just as easily called it bacon_search_form_length()

    Posted 2 years ago #
  10. Ok acknowledged.

    Thank you for this information! :) I really appreciate it.

    Best Regards,

    Drew

    Posted 2 years ago #
  11. no problem. if that solved it for you don't forget to mark this thread as resolved.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.