• Hello,

    I have just installed a child theme for the first time using WordPress instructions. I have no idea what to do with it and how they work!

    I want to remove the Designed by Themes & Co · at the bottom of the footer. How can I do this using the child theme, bearing in mind I don’t have a clue what to do!

    Thanks

Viewing 15 replies - 1 through 15 (of 22 total)
  • In your functions.php (which should be empty), add this code in between the php markup delimiters:

    add_filter('tc_credits_display', 'my_custom_credits');
    function my_custom_credits(){
    echo '<div class="span4 credits">
        		    	<p> &middot; &copy; '.esc_attr( date( 'Y' ) ).' <a href="'.esc_url( home_url() ).'" title="'.esc_attr(get_bloginfo()).'" rel="bookmark">'.esc_attr(get_bloginfo()).'</a> &middot; Designed by <a href="'.TC_WEBSITE.'">Themes & Co</a> &middot;</p></div>';
    }

    Of course, you’ll need to replace the part between the last two middots with your own stuff.

    Thread Starter AlbaFitness

    (@albafitness)

    Where??

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    You should be able to add that to your child theme’s functions.php file.

    Take a look at this post it’s exactly what you’re looking for.

    My post also explains an alternative solution using Widgets

    @ithril:
    In your solution, customizr/parts/class-footer-footer_main.php gets overridden by [child-theme-folder]/parts/class-footer-footer_main.php.
    This means that if in some theme update the author decides to improve or change the footer social links or the back-to-top link in the footer, anyone using my solution will benefit from the upgrade, while the ones using your solution will not, because the whole file from parent theme gets ignored. Also, my solution replaces a function, not a file, and will continue to work even if the parent function will be moved in another file or if the file structure changes and the theme expects a different output from class-footer-footer_main.php, while yours will graciously fail.

    @rdellconsulting: can you change the contents of the footer with your solution?

    @albafitness: that code should go in your functions.php file from your child theme folder, just before the ending line, which should remain intact and contain:

    ?>

    Actually, because your child theme is newly created and I assume you don’t have any other custom function added to it, just save the following code as functions.php in your child theme, replacing the old functions.php:

    <?php
    add_filter('tc_credits_display', 'my_custom_credits');
    function my_custom_credits(){
    echo '<div class="span4 credits">
        		    	<p> &middot; @copy; '.esc_attr( date( 'Y' ) ).' <a href="'.esc_url( home_url() ).'" title="'.esc_attr(get_bloginfo()).'" rel="bookmark">'.esc_attr(get_bloginfo()).'</a> &middot; {Replace this accolade with your link, Alba!} &middot; </p></div>';
    }
    // Add any future custom php functions after this line and make sure the last line of the file remains untouched!
    
    ?>

    There is one more very important instruction which I think you missed in my previous post, Alba:

    Of course, you’ll need to replace the part between the last two middots with your own stuff.

    To make it easier, this time I wrote {Replace this accolade with your link, Alba!} where your link should go.

    Thanks for the advice acub, now i have a bit of work to do with my site…
    The way you explain is the best, this way i can add many other functions without adding custom php files to my child theme.

    This is a really helpful and didactic post. Thank you! Now I finally understand the role of functions.php without wading through pages and pages of documentation ?? Thanks acub. I wish we had some sort of rating system for posts as this is one of the best.

    @nikeo Would you consider putting this in the FAQ? Maybe in a “For the adventurous” section at the bottom?

    <h3><strong>For the adventurous :</strong></h3>
    <ul>
    <li><a href="https://www.ads-software.com/support/topic/child-theme-footer" target="_blank">Understand the basics of using functions.php in Customizr?</a></li>
    </ul>

    @acub, my solution suppresses the Themes & Co footer and enables you to setup Footer Left/Centre/Right which contains any HTML you need. I think it’s the more flexible solution. No need for php knowledge.

    @electricfeet: this is the beauty of WP and its’ child themes system.

    functions.php of the child theme is an addition to functions.php of the parent theme.

    The really cool part is that the child version is read just before the parent version. Why is it so cool? Because it gives theme developers the ability to make their functions pluggable. To wrap them in a

    if( ! function_exists('name_of_function') ) {
      function name_of_function( $params ) {
      // do some stuff with the $params  }
    }

    This gives child theme ‘devs’ the ability to completely replace functions declared in the parent theme. By the time WP finds them in parent functions.php they exist and get skipped (because of the function_exists() condition).

    However, nikeo used another great feature of WP: apply_filters().
    This gives us the ability to declare (in functions.php of the child theme) a new function that filters the output of an existing one (so we’re not replacing the function, just alter/replace its output):

    add_filter('old_function', 'new_function');

    Now all you need to do is create the new_function() (also in your child theme’s functions.php). Without any parameter, it simply replaces the output of old_function with its own output:

    function new_function() {
    $new_output = 'New output';
    echo $new_output;
    }

    If you want the new_function to alter the content of old_function, declare it with one parameter, and that param will contain the output of the old_function:

    function new_function($output) {
    /* $output now holds the output of the old_function and you can alter
     * it as you want, using preg_replace or adding to it or hacking it
     * anyway you like. In this example I'm just adding $new_output after
     * the original output:
     */
    $new_output = '<div>This text has been added using apply_filters on old_function(), never touching parent theme core files! Cool, huh?</div>';
    echo $output.$new_output;
    /* Please note that some functions need the output echoed and others
     * want it returned, so you'll need to replace echo with return in
     * some cases. Just look at old_function() and you'll know.
     */
    }

    Hope this sheds some light on why WP’s slogan is “Code is poetry”. ??

    And why nikeo did such a great job with the dev tools. If you look in the tootips, you will see on last line:
    filterable with: add_filter(‘name_of_original_function’, ‘generic_name_for_new_function’); so you can add in your child theme’s functions.php

    add_filter('name_of_original_function', 'coolest_function_name_evah')
    function coolest_function_name_evah($original_output) {
    // filter and return/echo the output to your liking
    }

    And you’re done without having to worry about Customizr updates overriding your filter.

    Ah, I see! Yes, Nikeo is a very clever coder isn’t he?

    Thanks for the extra info. It’s really useful.

    I have created both the functions file and copied the class-footer-footer_main from the main theme and changed the credits but none of the solutions works. any ideas why?
    for motoridetransylvania.com

    Where did you put your style.css? (It’s not loading) What did you call your child theme directory?

    @acub thank you for your definitive explanation.

    @rdellconsulting I am still learning so will check your tips out also

    Theme Author presscustomizr

    (@nikeo)

    @acub, @electricfeed and @rdellconsulting : this is one of the best support thread ever! I just stumbled upon it.

    @acub, @electricfeed and @rdellconsulting thanks to you guys for such a quality support, it is really amazing.

    @electricfeet : the clever guy here is @matt Mullenweg, he just created this wonderful coding environment and made the life of millions people simpler! The only smart thing I did was to dive into the codex and try to apply WordPress best practices. But I am still far from beeing a rockstar!

    @acub I really think you should teach WordPress! (maybe you already do?)

    Bests!

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘Child theme & Footer’ is closed to new replies.