• Resolved dolphinsin

    (@dolphinsin)


    Hi guys,

    I’m trying to get my get_template_directory_uri() to work but for style, but my css is not working on front end. I did put this link in the header but I understand that is not the right way

    
    <link href="<?php bloginfo('stylesheet_url'); ?>" rel = "stylesheet">
    

    This is my code so far:

    
    <?php
    
    function lapizzaria_styles() {
    	// adding stylesheets	
    	wp_register_style('style', get_template_directory_uri() . 'style.css', array()
    );
    	// Enqueue the style
    
    	wp_enqueue_style('style');
    
    	wp_register_style('normalize', get_template_directory_uri() . '/css/style.css', array(), '7.0.0');
    	wp_enqueue_style('normalize');
    	
    	
    	
    }
    
    add_action('wp-enqueue_scripts', 'lapizzaria_styles');
    
    function lapizzaria_menus(){
    	register_nav_menus(array(
    		'header-menu' => __('Header Menu', 'lapizzaria'),
    		'social-menu' => __('Social Menu', 'lapizzaria')
    	));
    }
    
    add_action('init', 'lapizzaria_menus');
    ?>
    

    Any ideas welcome.

    • This topic was modified 6 years, 10 months ago by Jan Dembowski. Reason: Fixed code block

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter dolphinsin

    (@dolphinsin)

    I forgot to say that I have this function in the head:

    <?php wp_head(); ?>

    Moderator bcworkz

    (@bcworkz)

    You’ve hooked the action “wpenqueue_scripts”
    The correct action is “wp_enqueue_scripts”
    (all underscores, no hyphens)

    Thread Starter dolphinsin

    (@dolphinsin)

    Thanks, yes that would make a difference. I’ve correct that but it’s still not working. But thanks for your help.

    Thread Starter dolphinsin

    (@dolphinsin)

    I had the wrong file path as well and now it’s working. You are awesome for spotting that mistake.

    Thank you

    Moderator bcworkz

    (@bcworkz)

    You’re welcome. Checking the path would have been my next suggestion, you beat me to it ?? In my own experience, getting that right first try is harder than it seems.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_register_style not working’ is closed to new replies.