function works in parent, but not in child

Hello, 

I am trying to make a menu bar that changes depending on whether the site is being seen by a person who's logged in or logged out. I have found a code snippet that works perfectly fine for me, but only if I put it in the main, parent functions.php. If I put it in the child functions.php it doesn't work. Is there a good, direct way to determine whether the child theme is included or not, cause right now it doesn't seem to be, yet I've copied it from the package and didn't change anything on it. 

Regards, 
Stenaa

Comments

  • HI,
    the error is probably in your code because if you just want to change the functions.php file then everything should work fine. It is only the theme functions inside the functions folder that need to be required_once() in the functions file.
    thanks
  • Hello, 
    I'm not sure if we're talking about the same. If I put the code in the theme functions.php it does work fine. I am trying to put it in the child theme. Here's the code: 

    function my_wp_nav_menu_args( $args = '' ) {
    if( is_user_logged_in()) {
    $args['menu'] = 'logged-in';
    }else{
    $args['menu'] = 'logged-out';
    }
    return $args;
    }

    add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args’ );
  • Sorry but we do not know, you must have made a misstake in your code. The child theme functions.php works out of the box and does not need any more settings.
  • I have just updated the parent theme, and haven't made any changes to the child theme before yesterday. It only ever worked if pasted in the parent functions.php

    Is there a specific location in the file where the code should be pasted, or are they supposed to go to the end of the file? 
  • It does not matter where you place it as long as it is placed correctly.
    Which theme do you have activated, you should have the child theme active.
    thanks
  • I have both the theme and the child theme folders extracted in the wp-content/themes, i didn't change anything about the child theme since i extracted it from the file i downloaded from themeforest. The code works fine in the parent theme functions.php 

    I just don't see what I should do in order for my child theme to be working. All the contents of the child .zip are properly extracted, yet no changes applied to the child don't affect the site. 
  • Please send us WordPress dashboard and FTP access privately thru the contact form which is on the right side at http://themeforest.net/user/muffingroup#contact and we will check what might be the reason.

    Notice!
    Please attach a link to this forum discussion.


    Thanks
  • I wasn't aware the child theme needs to be activated in the dashboard. I have fixed the issue accidentally. I do appologize for wasting your time on this. :/
Sign In or Register to comment.