Adding a Function without a child theme?

  • Phil

    #10144

    Hi,

    Is there a simple way of adding a function to the Graphene theme without compromising future updates other than via a child theme? I want to add the following function(which I found in the forum):

    function two_sidebar_homepage(){
    global $graphene_settings;
    if ( is_home() ) {
    $graphene_settings['column_mode'] = three_col_center;
    }
    }
    add_action( 'template_redirect', 'two_sidebar_homepage' );

    It’s purpose is to allow two sidebars on the front page and one on the rest.

    It’s a pity, given all the people who’ve asked for this functionality on the various forums, that it’s not available out of the box, from either WordPress or the theme. Still, this little function works fine. Its just that it’s a pain to have to create a child theme and then set all the Graphene options again.

    Cheers

    Phil

    Mod

    Kenneth John Odle

    #45468

    The short answer to your question is no. If you want custom functions, you have to use a child theme.

    Quote:
    It’s a pity, given all the people who’ve asked for this functionality on the various forums, that it’s not available out of the box, from either WordPress or the theme.

    This isn’t a WordPress issue, it’s a theme issue. Themes control the appearance.

    Quote:
    Its just that it’s a pain to have to create a child theme and then set all the Graphene options again.

    You can export Graphene’s options, and then import them to your child theme. This should keep anything you have to set up again to a minimum.

    Additionally, using a child theme means that if you have a lot of settings (colors, etc.) you can move these to a child theme stylesheet, which will both speed up your site and reduce your server load.

    At one point, WordPress used to reset all your widgets when you changed themes, but now it keeps track of them, so that shouldn’t be an issue any more.

    Phil

    #45469

    Hi Kenneth,

    Thanks for your reply.

    That’s a good point about exporting and importing the graphene options. I’ll give that a go.

    Cheers

    Phil

    Mod

    Kenneth John Odle

    #45470

    Should work a treat. Let us know if you run into any problems.

    Phil

    #45471

    Yes, it pulled in the Graphene options but I need to sort out the menus, header and background images etc.

    I still think it would be nice if the Graphene theme included this. It does if you are using a static front page but not if it contains posts.

    Phil

    #45472

    Is there a way of adding the code in via an Action Hook rather than a child theme? As you can probably tell from my question I don’t fully understand how they work 🙂

    Phil

    #45474
    Quote:
    Is there a way of adding the code in via an Action Hook within the Advanced Graphene Options rather than a child theme? As you can probably tell from my question I don’t fully understand how they work 🙂

    I meant to say: Is there a way of adding the code in via an Action Hook within the Advanced Graphene Options

    Mod

    Kenneth John Odle

    #45475

    Not really. A function like that needs to be loaded with all the rest of the functions when the theme is called.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Do NOT follow this link or you will be banned from the site!