0

I am using a wordpress child theme and have added css code to the style.css and everything works well. When i want to add function to my function.php file I always get error message. I am new to using the child theme so my problem is to know where to place functions. Should all new functions be placed inside funtion.php or does it depend on each function.

function.php file:

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {

    $parent_style = 'PRANAYAMA_YOGA_THEME_VERSION'; // 

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}

For example i tried to add a onepage-nav function to my Menu, like this

  $('#nav').onePageNav({
    currentClass: 'current',
    changeHash: false,
    scrollSpeed: 750
  });
 /

But my site crashed.

Thanks in Advance

  • crashed by the php function? – Makiomar Aug 12 at 12:33
  • yes, when I insert this function in the php file the site crashes. I dont know exactly what it is that makes it crash but something about adding this function to the php file. – davidhlyns Aug 12 at 12:42
  • can you set WP_DEBUG to true so to display the error. you can find inside wp-config.php – Makiomar Aug 12 at 12:59
  • 1
    That’s not a PHP function. That’s JavaScript. You can’t put JavaScript in functions.php like that. – Jacob Peattie Aug 12 at 13:16
  • Yes that what i was thiking, I am new to using the wordpress child theme and placing the functions. Do I have to make a function and then call the function in the function.php folder ? – davidhlyns Aug 13 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.