Do it like shown below, as suggested by @gyo and done by @Howdy_McGee in his answer.
function admin_queue( $hook ) {
global $post;
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
if ( 'targeted-posttype' === $post->post_type ) {
wp_enqueue_script(
'custom-title-here',
bloginfo( 'template_directory' ) . '/scripts/custom-script.js',
'jquery',
'',
true
);
}
}
}
add_action( 'admin_enqueue_scripts', 'admin_queue' );
Related Posts:
- How to set time delay in javascript
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- My javascript is returning this error: $.ajax is not a function
- JavaScript: filter() for Objects
- JavaScript Loading Screen while page loads
- Rotate image with javascript
- How to make a simple image upload using Javascript/HTML
- javascript function wait until another function to finish
- Enable & Disable a Div and its elements in Javascript
- Javascript – ERR_CONTENT_LENGTH_MISMATCH
- The ‘describe’ keyword in javascript
- Is there a way to enable Cross-Origin Resource Sharing for WordPress’ ajaxurl?
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- Move WordPress native javascript to bottom of page?
- Ajax call does not activate callback function
- Using ‘$’ instead of ‘jQuery’ in WordPress
- Automatically decrease font size for long words
- Javascript included but alert() function not working
- Trying to get single posts to load on the front page via ajax
- Ajax not firing properly using Firefox, but works in Chrome
- jQuery Hoverintent plugin in TwentyEleven Menu [closed]
- How wp_enqueue_script works?
- Prevent five different copies of jquery from being included on every page
- Is placing stuff in page text edit window bad form?
- Script won’t execute in the media manager
- javascript is not working on Event Submission?
- Add colorpicker to featured image
- Gravity Forms not loading under https, jQuery is not defined
- wp_ajax unauthenticated and authenticated
- WordPress ajax function parameter value not being passed
- Is it safe to include a javascript file in a template’s php file?
- Add a Fancybox automatically to post type “post” images
- Enqueuing javascript files
- WordPress customizer refresh screen after save
- Creating multiple enclosing shortcodes and fixing JS issues on click
- Can’t load a class into WordPress post editor’s content field
- JSON output returns page source code [closed]
- Dealing with a library that depends on jQuery
- start.js:45TypeError: Not enough arguments on Safari [closed]
- How to Dynamically Load Content Into Body of Bootstrap Modal Window?
- I want to import my Json file into a custom made display-modal. How do i link my Json file?
- Help with a jQuery Carousel
- Searching multiple tags and adding jQuery dependant script onto page template?
- TinyMCE 4 remove/add attributes for all images
- Trouble with WordPress Ajax Login System – 302
- Javascript stopped working [closed]
- Fall Back Google CDN in JavaScript
- Why load JS through the CMS framework? [duplicate]
- Problem passing id-specific objects to javascript via wp_localize_script
- url – ajax loaded but no JS
- I have an old version of jQuery showing up. How do I figure out where it is coming from?
- Close Fancybox, sumbit form data and redirect
- Loading scripts on a single page plants the script in the footer
- Properly embed javascript into WP (using function.php) – doesn’t work?
- Search input area autogrow – how?
- Nested Gallery Shortcode INTERMITTENTLY working
- Get value of selected option in select field in a WordPress form
- How to keep HTML form field that is conditional hidden with javasript hidden after page reload?
- Accessing javascript in multiple files [closed]
- Issues loading Jquery on WordPress website
- Required radio button does not validate in form, when clicked through Javascript/jQuery
- Blur.js with WordPress – Enqueued, but server not finding file
- Parse wordpress blog data using json api and ajax
- Screen Options JavaScript Code
- Problem adding MP3 attachments to a jPlayer playlist
- Is there some jQuery conflict here?
- Theme has superfish – how to add supersubs?
- A carousel slideshow plugin in JavaScript
- Best way to add some custom javascript using jquery to a child theme
- JS behavior differs depending on page tree [closed]
- Add JQuery As Code Snippet
- Form validation before submitting
- jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser
- Get ajaxForm response value
- Site images are fixed in front of my site content [closed]
- onclick jquery function not working in wordpress header file [duplicate]
- JQuery toggle in Visual Composer
- jQuery not working for media uploader
- Adding scripts before plugins scripts
- How to toggle custom WP archive list
- WP Media Uploader modal conflicts with Bootstrap modal
- jQuery search function not running in WordPress but running locally (fiddle)
- JQuery Login Dropdown not functioning in theme
- Javascript function to switch out images
- Enqueue javascript that inserts custom php widget into jQuery-constructed div
- Retrieve customizer value using ajax or customizer api and print the value in theme
- Uncaught TypeError: undefined is not a function (shortcode-box)
- Running javascript in a child theme. Works in jsfiddle
- How to block action if post is “dirty”?
- Clear custom field when new tag is added
- WordPress video end function [duplicate]
- wp_register_script Question
- Ensure an external javascript file called from plugin is loaded after jquery is called
- Why my vertical tab js code is refreshing the page continuously? [closed]
- javascript not loading in wordpress
- bootstrap-slider.js by seiyria not working in wordpress
- Carousel Hover Image
- Individual Pages are loading halfway down
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]