Custom Footer


I want to change all the content in the footer. Doing beans_remove_markup for beans_footer_credit_left and beans_footer_credit_right did not remove all of it. I hesitate to remove the entire beans_footer_credit, because I want to keep that structure, just change the content. So I tried redefining that function in my functions.php file. For a little while (about 15 minutes), that worked like a charm. And then I got fatal error message:

Fatal error: Cannot redeclare beans_footer_content() (previously declared in [...tm-beans-child/functions.php:115]) in [...tm-beans/lib/templates/fragments/footer.php] on line 54.

So, I am confused about why it worked for a little while, then went to fatal error. (I thought a fatal error would show up immediately.) Also, I still want to change the footer content completely. How do I do that without this "previously declared" problem popping up?

Thanks!!


I took a different approach, with a snippet I came across here on the forum. Essentially it overwrites the beans_footer_content (which contains those left & right bits) completely.

// 10 Adding a Footer Bottom Area for all pages

// 10.1 Overwrite the Footer content

beans_modify_action_callback( 'beans_footer_content', 'beans_child_footer_content' );

function beans_child_footer_content() {

    ?>
    <div class="uk-grid uk-container-center uk-text-small" data-uk-grid-margin>
        <div class="uk-width-large-1-2 uk-text-center">
            <p class="uk-text-muted">Left</p>
        </div>

        <div class="uk-width-large-1-2 uk-text-center uk-clearfix">
            <p class="uk-text-muted">Right</p>
        </div>
    </div>
    <?php
}

As for the fatal error, I have no idea. Could it be that you tested a new page in the browser, or refreshed it - I had a few occasions where an edit wouldn't pick up right away unless I had development mode active?


Aha! I see what you have done -- and yes, it should solve my problem. Instead of directly redefining an existing function (what I did), you created a new function beans_child_footer_content and then told beans to use that instead of the existing beans_footer_content. I will go play with that, and am sure it will work.

Thank you!

As for the fatal error, still dunno. Yes, I was refreshing. Looking at the same page again and again. So perhaps there was caching -- except the browser (same browser) always showed me the new changes. And yes, I do have development mode active on the Wordpress UI, and am using canary Chrome developer tools. So . . . puzzlement continues.


Yup, worked perfectly!


I signed up for a free account on c9.io, in a nutshell it lets me test changes on the fly without running into issues. If something goes awry, I can step back, if I screw up WP it doesn't get in the way of things, pretty nifty. I can keep a pane open for development mode, code view, web view, etc.

I'm sure there is a way to not use the beans_footer_content, instead providing a new one without overwriting it, but that's way beyond me. I think it should be possible to contain such elements in their own php file for a child theme (like with the main theme), who knows. beans_modify_action_callback works - but it may not be the best or better method. I'm still figuring out when to use add_action versus add_smart_action 😛


Hey guys,

I just want to add a note, customizing the footer can be done at all levels depending on what you want to modify. If you want to replace the entire footer including the footer structural markup, then you would using the following:

beans_modify_action_callback( 'beans_footer_partial_template', 'example_footer' );

function example_footer() {
  // Replace footer the footer structural markup.
}

If you want to keep the wrapping markup and just modify the entire content and its markup, here is what you would use:

beans_modify_action_callback( 'beans_footer_content', 'example_footer' );

function example_footer() {
  // Replace footer content with its markup.
}

If you wanted to only replace the text, then you can use the beans_footer_credit_text_output filter for the left side text and beans_footer_credit_right_text_output filter for the right side text. For example, to replace the left side text you would do:

add_filter( 'beans_footer_credit_text_output', 'exemple_footer_left_text' );

function exemple_footer_left_text() {
 return 'Your text';
}

If you to understand more how {$markup-id}_output filters work, refer to this reply.

Regarding add_action vs beans_add_smart_action, it is quite simple to understand. beans_add_smart_action extends add_action and register it so that Beans Actions API functions can be used further. So in other words, you would only ever use beans_add_smart_action when building products meant to be distributed to public or if you plan on modifying your actions further. In most case when building websites, you would never use beans_add_smart_action.

Hope that helps,


Hi Thierry,

Yes indeed, that expands my understanding of what to use when. Thanks!!


I am a beginner web developer and came across the beans framework. What if I need to remove the footer for beans? Do I need still to create a function? Sorry the lame question. Thanks in advance.


Hi Abriel,

Welcome to Beans! The great thing about Beans is that you can get rid of anything you don't need, and customize everything you do need -- in a modular way. The learning curve is a little steep because there are so many "pieces". (I'm still in a pretty hilly place myself.) However, I am taking courage in hand and doing my best to reply.

First of all, yes, you usually put code to "change Beans stuff" into your child theme's functions.php file. Sometimes, you might want to put it into a template file instead. For example, if the special code would be used only on the home page, you could put it into your child theme's home.php file.

Here is an excerpt of something I added to my own functions.php file in order to remove the breadcrumb.

// Remove the breadcrumb.
add_filter( 'beans_pre_load_fragment_breadcrumb', '__return_true' );

Next, I encourage you to search for what you want to accomplish (in Google or other search engine) like this:

getbeans.io remove footer

The results often point you towards Beans community threads that either answer your exact question, or give you ideas to play with. One of those results showed this example for removing the header:

beans_remove_markup( 'beans_header' );

I bet you can do the same with the footer, like this:

beans_remove_markup( 'beans_footer' );

Though it's a good idea to make sure that beans_footer exists before just plomping it in there! (And yes, it does exist.)

You can also add or modify markup and attributes. This link gives many examples:

https://community.getbeans.io/discussion/header-footer-and-reusable-content/

Now, I don't guarantee that beans_remove_markup('beans_footer'); will do exactly what you want, but it's certainly where I would start if I were in your shoes.

Best wishes and happy coding! (And be sure to reply to this if you need more assistance. I've found folks on the community board to be Really Really Really helpful and responsive.)


Thanks Wyn! I'll take time to study the framework as well. Best regards!


You're welcome. Let us know if my idea worked the way you want.

Happy coding,


Hi Abriel,

If you want to completely remove the footer, you can add the following to your child theme functions.php:

beans_remove_action( 'beans_footer_partial_template' );

If you only want to remove the content, then you can do:

beans_remove_action( 'beans_footer_content' );

Finally if you want to replace the content, refer to these code snippets.

Happy coding,

Write a reply

Login or register to write a reply, it's free!