• I have not gone live yet because I don’t want my site to go down, but I went to the www.remarpro.com site to get info on how to create a stylesheet and I think there might be errors in the displayed enqueuing code.

    Here’s what it shows:

    
    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
     
    }
    ?>
    

    It then follows with:

    
    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
     
        $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
     
        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')
        );
    }
    ?>
    

    I’m pretty sure I need to replace the > with >, but I don’t think that’s the only problem as the editor I’m using says that the & in & is incorrect. Can someone help me confirm all of the sections I need to replace in this one and advise if someone can go to the website and fix that so that others don’t get the wrong information?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter OscarGuy

    (@oscarguy)

    Weird, the parts that were a problem > were fixed when I put them in code here. That’s very odd.

    Thread Starter OscarGuy

    (@oscarguy)

    I copied and pasted what generated above and it still does not work. Here’s the contents of the functions.php file as I currently have it. I am using the “Live Preview” to make sure that it works before going further and it still doesn’t.

    
    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        $parent_style = 'frontier'; 
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'frontier-child',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    add_filter( 'the_content_more_link', 'modify_read_more_link' );
    function modify_read_more_link() {
    return 'Click here to continue reading this article';
    }
    ?>
    
    • This reply was modified 5 years, 6 months ago by OscarGuy.

    Hey guy! What are you trying to do? A child Theme?

    Thread Starter OscarGuy

    (@oscarguy)

    Yes.

    Please, take a look in your browser inspector and see in the network tab what is the state of the style.css, if there is a style.css with status 404, try to activate another theme and then activate again your child-theme.

    Thread Starter OscarGuy

    (@oscarguy)

    So the code above is correct? That’s what I’m trying to verify. I am previewing the changes with the live preview functionality of the themes as I don’t want to activate the child and find the entire site goes down.

    I’ve take a look in the Child Theme page of WordPress and at a child theme I’ve created. I think you should put the string “frontier-style” as it says in the comment after the $parent_style variable for the Twenty Fifteen Theme. I let my child-style as it is in the code in the Child Theme WordPress page.

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
     
        $parent_style = '<strong>frontier-style</strong>'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
     
        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')
        );
    }
    • This reply was modified 5 years, 6 months ago by roscfi. Reason: Make it clearly
    Thread Starter OscarGuy

    (@oscarguy)

    Here’s how it currently looks (I may have modified it at some point) and I have changed it to show frontier-style where indicated and it still does not appear to work.

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
         $parent_style = 'frontier-style';
         wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'frontier-child',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    add_filter( 'the_content_more_link', 'modify_read_more_link' );
    function modify_read_more_link() {
    return 'Click here to continue reading this article';
    }
    ?>

    You’re calling a function twice with the add action.

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {...

    And I think that’s not going to works well.
    Try to replace the code you have in your functions.php for:

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
     
        $parent_style = 'frontier-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
     
        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')
        );
    }

    @oscarguy any news?

    Thread Starter OscarGuy

    (@oscarguy)

    I apologize for not responding sooner. I have consistently not found any time to work on this. That seems to have fixed the problem. Thank you.

    Now I just have to figure out how to get some of other changes I’ve made into my style sheet because apparently, I’ve made some others and I’m not sure where the differences are…that, though, might just take a line-by-line comparison of the base style sheet and the one I later created…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Problem Getting Child Theme Functions.php Right’ is closed to new replies.