This code will check to make sure that the Our People page is being viewed (page with slug our-people
) or one of the children of page with ID 597, and will enqueue both the JavaScript and CSS if so:
function wpse241030_scripts() {
// Bail if we're not looking at the Our People page or one of the children of page with ID 597.
if ( ! is_page( 'our-people' ) && ! in_array( 597, (array) get_post_ancestors( get_the_ID() ) ) ) {
return;
}
// Enqueue unslider JS
wp_enqueue_script( 'unslider-js', get_stylesheet_directory_uri() . '/library/js/unslider-min.js', array( 'jquery' ), '1', false );
// Enqueue unslider CSS
wp_enqueue_style( 'unslider-css', get_stylesheet_directory_uri() . '/library/css/unslider.css', array(), '', 'all' );
}
add_action( 'wp_enqueue_scripts', 'wpse241030_scripts' );
Related Posts:
- I have problems with loading javascripts
- Run a jquery script on on a certain template page
- Theme JS is available but theme CSS isn’t
- custom post with loading script per single post
- call of javascript function to external url always blocked by cors
- Including a specific Javascript Script in a template. Is my code correct?
- Remove stylesheets from Campaign Monitor plugin
- How to search using ajax for exact phrase or words in an input field?
- enqueue styles for only mobile wp
- Functions For Calling Specific Elements
- how to en-queue jQuery to load before the tag
- Overwriting the menu break points of twentysixteen in child theme
- How do I remove the date and category form my portfolio pages
- Full page template function
- I can’t enqueue my scripts – They literally aren’t being added to my site
- Javascript function not working when placed in Text Block
- different style sheet for just one page template
- wordpress use single ajax in place of multiple ajax requests in a smarter way
- Add Element as a Filter to the_content
- Pass variable from action back to template
- Need print logo without any ID & class
- Define PHP variable from a seperate API if statement
- Scripts not loading when using the wp_enqueue_scripts action
- Adding javascript to functions.php causes problems with my template
- Dequeue script to prevent javascript event conflict on wordpress child theme
- Split Media Queries in different files!
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- javascript and css links not working on sever
- Best way to handle lack of titles in microblogging
- attachment page template? only show attachments for current post?
- Enable right click on WordPress site
- How to include any template using Shortcode fuction?
- Image loading function not working on archive.php template
- Add a field into a shortcode of an extension
- Parent theme styles overriding child theme CSS [closed]
- The correct way to add a JavaScript in the functions.php [closed]
- I can’t add CSS with functions.php
- Javascript not loading after the document ready
- Proper Way to Load stylesheet on Condition
- Specify multiple categories for custom post template – FATAL ERROR
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Need help with customalert that it would read on a normal page, but not in WordPress
- Using functions.php to include code that’s processed inline
- How to load jQuery in TOP of wp_footer?
- How to make a new function that includes a template
- get_template_directory_uri() links to child theme not parent
- How to pass variables from one function to another or combine functions
- Do we need to change our child function.php to require/include child dir files when we add an over-riding file.php into the child theme
- Include Jquery libraries in wordpress theme?
- Page Template Won’t Load Correct CSS File
- Linking Javascript in functions.php file
- Dequeue scripts in IE7 only using functions.php
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Creating multiple category drop down
- Show admin page, only if function is being used
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- How to setup a popup registeration page in wordpress with function.php
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Prevent creating multiple image resizes in twentytwelve template
- Custom attributes to javascript tags
- wp_enqueue_script() not working
- Simplest Way to Build Custom Archives Page?
- Display ACF category image on archive and single template files
- How to change text color depending on the number value (Using javascript)
- Add custom taxonomy using JS in post editor
- Render page with specific id from functions.php
- wp_set_object_term via js btn frontend
- Advanced method to control cache of enqueued style/script
- How to require a config file in a template and in function.php?
- the_date() and the_time() functions display actual date an time instead of published date and time
- Load templates, pass arguments, and render output from functions.php
- Display Script in Header When URL Variable Present
- Changing the HTML of notices in WooCommerce [closed]
- Add custom css file after plugin css with WordPress Child Theme functions.php
- Running javascript without hooking wp_head
- wp enqueue style on about us page
- How to reference different css (bootstrap) stylesheets for the header and body of a page?
- Test CDN link from function.php or wp_enqueue_script/style?
- CSS style and app.js not loading
- Stylesheet does not load despite functions.php
- Ajax in plugin fails – but only on one blog – no idea why
- How to make the RTL.css the dominant css code?
- How to add javascript code into Divi child theme?
- Changing the default view of “The Events Calendar” for mobile
- How do I create a child theme from PowerMag theme
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Help wiht adding fullcalendar.io to a WordPress page
- WP Enqueue Script Error
- Multiple Notifications SetInterval
- More than one search results page template for two searches on site
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- WordPress function with attribute pass to template
- Child Theme not loading multiple stylesheets
- I need to ‘wp_dequeue_script’ and ‘styles’ and ADD a bunch of other css and js
- Get child-pages slugs of current page into js-file
- admin-ajax.php & my wp-admin folder url showing in header
- Why is style.css not loading through the functions.php
- Some code is added automatically to my site’s header – what is it?
- wordpress ajax is not working for dropdown selection