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
- How to load scripts/styles specific for a page
- How to redirect to post if search results only returns one post
- Where and how to put inline js in pages
- How to override admin-bar style
- wp_get_attachment_image returns different image size
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- TinyMCE custom stylesheets for different post types
- How to fix a theme with page.php Default Template that accidentally deleted?
- WordPress Change Post Templates,but not drop down, but Image selection
- Dequeue Scripts and Style for Mobile not working?
- Using locate-template & shortcodes doesn’t appear to work
- Run Product Filter Javascript On Page Template
- How to set global variables in template page?
- Why isn’t is_page_template() adding a body class?
- Enqueuing Script in functions.php vs on the page
- Query children and parent title
- jquery won’t load in footer
- If is multiple page templates
- How to properly add NPM packages and integrate them in WordPress?
- How to include local menu based on page id?
- Register and enqueue style.css custom theme
- Get Current User info using wp_localize_script, in functions.php
- How to create function from code?
- How to get the post_name when in preview?
- Default Gallery Edit/Template Editable?
- Replace menu links with # and add name to its li
- Retrieve tags data in post body
- functions.php How to add css/js depending on Template Name?
- Scripts not appending to element in AJAX call – why?
- Including a specific Javascript Script in a template. Is my code correct?
- Functions For Calling Specific Elements
- how to en-queue jQuery to load before the tag
- How do I remove the date and category form my portfolio pages
- different style sheet for just one page template
- Pass variable from action back to template
- 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
- 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
- How to include any template using Shortcode fuction?
- Image loading function not working on archive.php template
- I can’t add CSS with functions.php
- Javascript not loading after the document ready
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- Using functions.php to include code that’s processed inline
- How to load jQuery in TOP of wp_footer?
- 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
- 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
- How to setup a popup registeration page in wordpress with function.php
- 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
- Add custom taxonomy using JS in post editor
- Advanced method to control cache of enqueued style/script
- How to require a config file in a template and in function.php?
- Load templates, pass arguments, and render output from functions.php
- 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
- Test CDN link from function.php or wp_enqueue_script/style?
- Stylesheet does not load despite functions.php
- 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 To Display Author Popup on Entry Meta (Genesis Framework)?
- Help wiht adding fullcalendar.io to a WordPress page
- WP Enqueue Script Error
- How do I dequeue a Stylesheet, stored in an ‘Assets’ folder?
- WordPress function with attribute pass to template
- Get child-pages slugs of current page into js-file
- Some code is added automatically to my site’s header – what is it?
- Automatic add space if user enters number(any digit)
- Search and Replace Script Loader in Head Only Works in Footer
- How to pass a variable from a template page to the child theme functions.php
- Why are some custom javascript files working but some are not
- WordPress Javascript Widget jQuery Dependency Issue
- Shortcode to output get_header not working
- using enqueue_script in a shortcode isn’t working
- How do I get my nav menu to show sub pages?
- Why wp_ajax hooks doesn’t work?
- My website is generating weired url parameters of paginated pages
- Animated Accordion [closed]
- Get all users from role and add to dropdown (select) – wordpress, javascript
- Can’t find function which is called in a wordpress theme
- WordPress enque the same script causes the setInterval not to work
- How to store page-{id}.php templates in custom folder
- iOS and ajaxComplete