• Resolved readwriteandedit

    (@readwriteandedit)


    Since the Adamos stylesheet is enqueued in the Adamos functions.php, I thought that was where I should add the reference to the print.css as well, but I’m having trouble getting it to work.

    The relevant section from the parent functions file is

    /**
     * Enqueue scripts and styles
     */
    function adamos_scripts() {
    	wp_enqueue_style( 'style', get_stylesheet_uri() );
    
    	if (!is_admin()) {
    	wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true );
    	}
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    		wp_enqueue_script( 'comment-reply' );
    	}
    
    	if ( is_singular() && wp_attachment_is_image() ) {
    		wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
    	}
    
    	if (!is_admin()) {
    		wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'adamos_scripts' );

    ——-
    I copied this entire section to the child functions file, at the same time adding wp_enqueue_style( 'print', get_print_uri() );' directly underwp_enqueue_style( ‘style’, get_stylesheet_uri() );’

    But when I updated the child functions file, the file was blanked out (the white screen of death).

    I’m not sure where I went wrong. Any help is welcome.

    The print file is print.css and it exists only in the Adamos parent theme.
    The site is TheEditorsBlog.net/members (it’s an incomplete site)

    Thank you for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • First, it’s not necessary to copy that function from the parent theme to the child theme: WordPress will automatically load the functions.php from both the child theme and the parent theme.

    There is no function get_print_uri(). Instead, you can assign media queries with wp_enqueue_style():

    function adamos_child_scripts() {
      wp_enqueue_style( 'adamos-child-print', get_template_directory_uri() . '/print.css', null, null, 'print' );
    }
    add_action( 'wp_enqueue_scripts', 'adamos_child_scripts' );
    Thread Starter readwriteandedit

    (@readwriteandedit)

    Stephen, thanks for the quick answer. (Can you tell that I’m only copying the code? I don’t really know what I’m doing.)

    One more question–can I put this anywhere in the functions.php? That is, does it go inside the section I quoted above or should it be separate from that, existing as its own section of code?

    My thanks again.

    You don’t need to use the first bit of code you quoted. Instead, you can just use the code I posted. Your child theme’s complete functions.php could be:

    <?php
    function adamos_child_scripts() {
      wp_enqueue_style( 'adamos-child-print', get_template_directory_uri() . '/print.css', null, null, 'print' );
    }
    add_action( 'wp_enqueue_scripts', 'adamos_child_scripts' );
    Thread Starter readwriteandedit

    (@readwriteandedit)

    Okay, thanks. For some reason I was thinking I was putting this into the parent functions.php. I’ve got it now.

    My thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to enqueue Print CSS in Adamos child theme’ is closed to new replies.