Welcome to PressWork!

Want to ask a question or join the discussion? Great! Join now.

In this Discussion

Modifying existing functions in functions.php of child theme rather than core files
  • I'm using the latest installs of both PressWork and WordPress

    Hello !

    I've noticed that you guys love child themes so I've given them a go.

    I've added a few functions but now I'd like to edit/overwrite some instead.

    I'm using a plugin called ubermenu to replace the primary nav with a "mega menu".

    Uber Menu's instructions have asked me to change the #nav id in functions.php so PressWork's Tool-bar styles don't override mega menu's styling.

    this works fine if I edit the core files ... So how do you replace the core code rather than just adding to it?

    Snippet from core functions.php
    if($name=="nav") {
    $handle = pw_handles('Primary Nav Menu', 'nav', true, 'header');
    if(function_exists('wp_nav_menu')) {
    echo '<li id="nav" class="mainl">';
    echo $handle;
    echo '<nav class="clear fl" role="navigation">';
    echo '<h3 class="assistive-text">Main menu</h3>';
    wp_nav_menu( array( 'theme_location' => 'primary', 'sort_column' => 'menu_order', 'container' => '', 'fallback_cb' => 'pw_menu_default' ) );
    echo '</nav>';
    echo '</li>';
    }
    }



    If I could somehow add the edited version (say with #nav2) to functions.php in my child them that would be excellent!

    I realise this is a small edit but I want to see how this work before I move onto something more challenging :)



    This is my functions.php in my child theme
    <?php
     
    register_sidebar( array(
    'name' => __( 'Home A', 'Liam Digital' ),
    'id' => 'homepage_a',
    'description' => __( 'The first custom widget on the homepage', 'Liam Digital' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
     
    register_sidebar( array(
    'name' => __( 'Home B', 'Liam Digital' ),
    'id' => 'homepage_b',
    'description' => __( 'The second custom widget on the homepage', 'Liam Digital' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );
     
    ?>




    Thanks Alot ... PressWork Rules!
    Post edited by DeepTitanic at 2011-09-01 10:33:18
  • That code block is around line 872 in functions.php. There is actually no hook to customize that element since it is part of the drag and drop functionality.
    image Senior Developer & Co-Founder of PressWork