Here’s an example using the default WordPress is_page_template
function:
<?php
if ( is_page_template( 'base-gallery-rail.php' ) ) {
wp_enqueue_style('ztheme-gallery-style');
} else if ( is_page_template( 'other-template.php' ) ) {
wp_enqueue_style('other-style');
} else { // the last else is only required if you want to have a default
wp_enqueue_style('default');
}
You can add as many else if ( blah ){ //do stuff }
as you need. If you get above four or five, consider using a switch
statement.
Related Posts:
- Check if a menu is empty?
- How To Make Connection To WordPress Data Base In A Plugin?
- WordPress Template Engine?
- Walker class: Problems with understanding how walk() method can be called without error
- How to get the post count for the last x days filtering by categories
- Display only text to WordPress loop without loosing the text formatting
- How to create shortcodes that pull custom field data from general settings
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- How to display related posts from parent category
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- How do I translate this string – PHP syntax question
- Warning when using
- How to break down importing of feeds
- How to override wp-admin styling
- WordPress shows registration link for non logged users
- How to get woocommerce cart content without an action?
- How can I resolve the php notice “Constant EMPTY_TRASH_DAYS already defined”
- Use wp_get_recent_posts with search term
- multiple if statements [closed]
- Escape post image attachments added to template
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Bridging TinyMCE js and WordPress PHP?
- Echo URL of large version of Featured Image
- Add prefix to link url
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Change list item content in menu navigation to add a child element with specific class
- Selectbox in admin panel function linking to CSS
- Is it better to create a function or a variable for current_theme_supports?
- wordpress allow user to edit user profile with custom fields
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- WordPress admin dashboard missing icons
- Which field should I edit to make the checkbox marked by default?
- Add filter when image is uploaded?
- How can I save unique user data on my site? [closed]
- Add New User, extra fields which are required?
- Repeating admin-ajax.php not found error in admin
- Remove a div from RSS feed
- Keyword checking in Gravity Forms
- how to refresh div on template part?
- Any way to add -1 suffix to the end of every new post?
- Are all hooks/functions tied to Kses meant for sanitization?
- Get URL Parameters from referer
- Using custom tables for old posts
- Adding logo to WordPress header
- Change page title from page using php via php executed from page/post itself
- Download images from media library to computer in BULK?
- add_filter only for front office
- How to array only one key from another array
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Form Submission Not Working In Custom Theme
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Delete or edit postmeta with specific meta_key?
- Concatenate Custom Field Value & HTML Value
- How do I properly code my footer? See example
- how to hide or disable some part in specify page
- Use of IF statement in Header file
- Kohana Frontend, WordPress Backend
- apply_filters with several different values?
- Advanced Query posts
- Triggering a timewall after X days
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- echo cutom css code to WordPress page template file ? is this safe?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- PHP `iconv` not working inside a WordPress site
- How to make a “page-option” in WordPress
- Replacing entire tag with shortcode – JavaScript [duplicate]
- How do I visualize the author’s post from the front end?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Query to show average # of months all accounts with specific role have been active
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Use PHP to inject HTML into before page renders?
- Query doesn’t display text data with apostrophes
- WooCommerce Custom Tab with ACF Repeater Field
- My WP Website Shows HTTP ERROR 500
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- soap request in wordpress for a fedex pickup request [closed]
- Dynamically Create Posts Via XML File
- pages disable after wordpress update
- How to only fetch certain Tag ID’s
- Create server side text from wordpress page
- AdWords API with WP
- How to set a cookie based on a page Get variable?
- Editing the contents of just one div on a page from wordpress
- Postmeta not saving
- How to change the menu color
- Display latest 5 posts on homepage
- Display Current Time using shortcode
- Can’t insert into a database wordpress
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress