SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    724
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Need to add more than one parameter to a function.

    this is what I put in:

    Code:
    function infoLegalPrivacy_style() {
    	if( is_page_template('legalSub.php','privacySub.php') ) :
    	wp_register_style('my-style', get_stylesheet_directory_uri() . '/css/infoLegalPrivacy.css', array(), '', 'all' );
    	wp_enqueue_style( 'my-style' );
    	endif;
    }
    add_action('wp_enqueue_scripts', 'infoLegalPrivacy_style');
    but while the legalSub page recognizes the appropriate css the privacySub doesn't.
    Did I put it in incorrectly? is there a diff way. Or is it one by one?
    thx
    D

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function infoLegalPrivacy_style() {
    	if( is_page_template('legalSub.php' || 'privacySub.php') ) :
    	wp_register_style('my-style', get_stylesheet_directory_uri() . '/css/infoLegalPrivacy.css', array(), '', 'all' );
    	wp_enqueue_style( 'my-style' );
    	endif;
    }
    add_action('wp_enqueue_scripts', 'infoLegalPrivacy_style');
    || is the php operator for "or", and the function is_page_template is either true or false, so this might work. I haven't tested it though.

  3. #3
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    WordPress is in PHP, any code you write is in PHP. is_page_template() accepts only one parameter so why are you forcing more than one into it?

    Code:
    function infoLegalPrivacy_style() {
    	if( is_page_template( 'legalSub.php' ) || is_page_template( 'privacySub.php' ) ) {
    		wp_register_style( 'my-style', get_stylesheet_directory_uri() . '/css/infoLegalPrivacy.css', array(), '', 'all' );
    		wp_enqueue_style( 'my-style' );
    	}
    }
    
    
    add_action( 'wp_enqueue_scripts', 'infoLegalPrivacy_style' );
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •