• Resolved samtemehr

    (@samtemehr)


    hi
    I want
    index.css => only for index.php
    newstext.css => only for single.php
    and
    index.js => only for index.php
    newstext.js => only for single.php

    function et_load_samtemehr_scripts() {
    	$template_dir = get_template_directory_uri();
    
    	$theme_version = et_get_theme_version();
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
    		wp_enqueue_script( 'comment-reply' );
    	wp_enqueue_script( 'samtemehr-superfish', $template_dir . '/js/jquery.cookie.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-fitvids', $template_dir . '/js/jquery.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-index-min', $template_dir . '/js/index.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-flexslider', $template_dir . '/js/jquery.flexslider.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-bootstrap', $template_dir . '/js/bootstrap.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_style( 'samtemehr-bootstrap', $template_dir . '/css/bootstrap.min.css' );
    	wp_enqueue_style( 'samtemehr-index-min', $template_dir . '/css/index.min.css', $theme_version, true);
    	wp_enqueue_style( 'samtemehr-iconic-font', $template_dir . '/css/iconic.min.css', $theme_version, true);
    
Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Thread Starter samtemehr

    (@samtemehr)

    @sterndata

    function samtemehr_index_scripts() {
    	if ( is_page_template( 'index.php' ) ) {
    			wp_enqueue_style( 'samtemehr-index-min', get_stylesheet_directory_uri() . '/css/index.min.css');
    			wp_enqueue_script( 'samtemehr-index-min', get_stylesheet_directory_uri() . '/js/index.min.js' );
    	}
    }

    not loaded.

    • This reply was modified 6 years ago by samtemehr.
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Did you add the “add_action” line?

    add_action('wp_enqueue_scripts', 'samtemehr_index_scripts' );

    Thread Starter samtemehr

    (@samtemehr)

    @sterndata

    not loaded…

    function samtemehr_index_scripts() {
    	if ( is_page_template( 'index.php' ) ) {
    			wp_enqueue_style( 'samtemehr-index-min', get_stylesheet_directory_uri() . '/css/index.min.css' );
    			wp_enqueue_script( 'samtemehr-index-min', get_stylesheet_directory_uri() . '/js/index.min.js' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'samtemehr_index_scripts' );
    
    function et_load_samtemehr_scripts() {
    	$template_dir = get_template_directory_uri();
    
    	$theme_version = et_get_theme_version();
    
    	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
    		wp_enqueue_script( 'comment-reply' );
    	wp_enqueue_script( 'samtemehr-superfish', $template_dir . '/js/jquery.cookie.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-fitvids', $template_dir . '/js/jquery.min.js', array( 'jquery' ), $theme_version, true );
    	
    	wp_enqueue_script( 'samtemehr-flexslider', $template_dir . '/js/jquery.flexslider.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-bootstrap', $template_dir . '/js/bootstrap.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_style( 'samtemehr-bootstrap', $template_dir . '/css/bootstrap.min.css' );
    	
    	wp_enqueue_style( 'samtemehr-iconic-font', $template_dir . '/css/iconic.min.css', $theme_version, true);
    
    	/*
    	 * Loads the main stylesheet.
    	 */
    	wp_enqueue_style( 'samtemehr-style', get_stylesheet_uri(), array(), $theme_version );
    }
    add_action( 'wp_enqueue_scripts', 'et_load_samtemehr_scripts' );
    
    if ( ! function_exists( 'et_get_theme_version' ) ) :
    function et_get_theme_version() {
    	$theme_info = wp_get_theme();
    
    	if ( is_child_theme() ) {
    		$theme_info = wp_get_theme( $theme_info->parent_theme );
    	}
    
    	$theme_version = $theme_info->display( 'Version' );
    
    	return $theme_version;
    }
    endif;
    
    • This reply was modified 6 years ago by samtemehr.
    • This reply was modified 6 years ago by samtemehr.
    • This reply was modified 6 years ago by samtemehr.
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I don’t see that you included the code I specified.

    Thread Starter samtemehr

    (@samtemehr)

    my code is this.
    But not loaded…

    function et_load_samtemehr_scripts() {
    	$template_dir = get_template_directory_uri();
    	$theme_version = et_get_theme_version();
    	
    	wp_enqueue_script( 'samtemehr-superfish', $template_dir . '/js/jquery.cookie.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-fitvids', $template_dir . '/js/jquery.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-bootstrap', $template_dir . '/js/bootstrap.min.js', array( 'jquery' ) , $theme_version, true );
    	wp_enqueue_style( 'samtemehr-bootstrap', $template_dir . '/css/bootstrap.min.css' );
    	wp_enqueue_style( 'samtemehr-iconic-font', $template_dir . '/css/iconic.min.css', $theme_version, true);
    	wp_enqueue_style( 'samtemehr-style', get_stylesheet_uri(), array(), $theme_version );
    	
    	//***** this is your code *****//
    	if ( is_page_template( 'single.php' ) ) {
    	 wp_enqueue_script( 'samtemehr-index', $template_dir . '/js/index.min.js', array( 'jquery' ), $theme_version, true );
    	 wp_enqueue_style( 'samtemehr-index', $template_dir . '/css/index.min.css', $theme_version, true );
    	}
    	
    }
    add_action( 'wp_enqueue_scripts', 'et_load_samtemehr_scripts' );
    Thread Starter samtemehr

    (@samtemehr)

    I found. ??

    function et_load_samtemehr_scripts() {
    	$template_dir = get_template_directory_uri();
    	$theme_version = et_get_theme_version();
    	
    	wp_enqueue_script( 'samtemehr-superfish', $template_dir . '/js/jquery.cookie.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-fitvids', $template_dir . '/js/jquery.min.js', array( 'jquery' ), $theme_version, true );
    	wp_enqueue_script( 'samtemehr-bootstrap', $template_dir . '/js/bootstrap.min.js', array( 'jquery' ) , $theme_version, true );
    	wp_enqueue_style( 'samtemehr-bootstrap', $template_dir . '/css/bootstrap.min.css' );
    	wp_enqueue_style( 'samtemehr-iconic-font', $template_dir . '/css/iconic.min.css', $theme_version, true);
    	wp_enqueue_style( 'samtemehr-style', get_stylesheet_uri(), array(), $theme_version );
    	
    	//***** this is your code *****//
    	if ( !is_single() ) {
    	 wp_enqueue_script( 'samtemehr-index', $template_dir . '/js/index.min.js', array( 'jquery' ), $theme_version, true );
    	 wp_enqueue_style( 'samtemehr-index', $template_dir . '/css/index.min.css', $theme_version, true );
    	}
    	if ( !is_front_page() ) {
    	 wp_enqueue_script( 'samtemehr-content', $template_dir . '/js/newstext.min.js', array( 'jquery' ), $theme_version, true );
    	 wp_enqueue_style( 'samtemehr-content', $template_dir . '/css/newstext.min.css', $theme_version, true );
    	}
    	
    }
    add_action( 'wp_enqueue_scripts', 'et_load_samtemehr_scripts' );
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How instal more css file to more page?’ is closed to new replies.