So I've been messing with this for a while now and I don't understand how I'm unable to pull in my style file properly by registering and calling it at all.

Here is my method:

public static function register_styles()
    add_action('wp_enqueue_scripts', function() {
        global $post;

        if (is_page('foodies')) {

            //Adding stylesheets
            wp_register_style('profile-style', '/Users/smajlovs/Sites/newsacfoodies/htdocs/wp-content/mu-plugins/sacfoodies/styles/style.css');

            //Enqueue the style
            wp_enqueue_style('profile-style', '/Users/smajlovs/Sites/newsacfoodies/htdocs/wp-content/mu-plugins/sacfoodies/styles/style.css');

        if ($post->post_type == 'profile') {
            echo 'Hello! I am the register_styles method on the profile custom post type page';


Within my main sacfoodies.php file, I'm calling Profile::register_styles().

The confusing part is, the var_dump that I have inside that function actually dumps out the hello on that page as shown here:

var_dump(wp_enqueue_style('profile-style')); returns null

So does anyone know why my enqueue register and call won't render my style.css file? I have the absolute path in there for testing purposes and nothing.

  • 2
    You need to use a URL when enqueuing scripts and styles. You can't use a path. Jan 28 '20 at 5:14

Call like this. It may be help you.

  • 1
    Thanks @Tanway Patel, the content_url() worked.
    – SLE
    Jan 28 '20 at 21:13

If we getting expected result up to var_dump('Hello!'); than can we replace below 2 lines as following..

wp_register_style('profile-style', WPMU_PLUGIN_URL.'/sacfoodies/styles/style.css');

let me know reflected changes....

Thank you


Something like this should work

add_action( 'wp_enqueue_scripts', 'enqueue_styles' );
function enqueue_styles() {

if ( is_page('foodies') ) {

    wp_enqueue_style( 'your-styles', get_stylesheet_directory_uri() . '/css/style.css' );

Swap out the get_stylesheet_directory_uri() . '/css/style.css' to match the path to your style sheet.

Your Answer

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

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