1

I'm creating my own theme in WordPress, trying to link external stylesheet.

My code is:

call_user_func_array( $the_['function'], array_slice( $args, 0, (int)$the_['accepted_args'] ) );

but it returns the error:

call_user_func_array() expects parameter 1 to be a valid callback, second array member is not valid method in

I've got no idea what's wrong.

2 Answers 2

0

What that error means is that $the_['function'] is an array, and so PHP is attempting to interpret $the_['function'][0] as an object and $the_['function'][1] as a method of that object, and a method of that name does not exist on the object. From the manual on callbacks:

A method of an instantiated object is passed as an array containing an object at index 0 and the method name at index 1.

So you need to check the contents of $the_['function'] to figure out what exactly is in there and how you should be calling call_user_func_array().

0

The right way to include an external stylesheet is as follows:

function enqueue_custom_styles() {

    /*Enqueue The Styles*/
    wp_enqueue_style( 'themename', get_template_directory_uri() . '/css/custom.css' );

}

add_action( 'wp_enqueue_scripts', 'enqueue_custom_styles' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.