If you remove that conditional in the first line of the enqueue function, your scripts should load. I can’t see the broader context of why your function is written that way, but if you just copied it from a tutorial or something, you don’t need it here.
Try:
<?php
function sunset_load_admin_scripts(){
wp_enqueue_media();
wp_register_script('sunset-admin-script',get_template_directory_uri() .'/js/news_admin.js', array('jquery'), '1.0.0', true);
wp_enqueue_script('sunset-admin-script');
}
add_action( 'admin_enqueue_scripts', 'sunset_load_admin_scripts' );
Please note admin_enqueue_scripts will only enqueue scripts for the back-end of your site, not the front-end. You can replace it with wp_enqueue_scripts if you want it to work on the frontend.
Related Posts:
- Adding scripts to admin page in my theme
- How to enable enqueue_script to work with a logged in user?
- How can I load an inline script after the enqueued scripts in admin?
- jQuery UI AutoComplete & wp_enqueue_script
- Unable to upload image using the standard uploader in the WP admin (v4.3)
- How to enqueue admin content outside admincp
- admin_enqueue_scripts not rending JS file correctly
- Include script files for admin submenu page
- Load stylesheet on custom admin submenu page
- Enqueue script throws error in console
- Admin Ajax is returning 0
- Add a Separator to the Admin Menu?
- Adding a custom admin page
- Allowing admin-ajax.php to receive “application/json” instead of “x-www-form-urlencoded”
- Custom admin email for new user registration
- A similar hook as wp_head for the admin area
- How do I set up a webhook?
- Hide allow trackbacks/pingbacks
- How to retain HTML5 Attributes on Markup
- Gallery Settings Change available Columns
- Hide Admin menus per role in WordPress
- wordpress upload http error?
- Dynamically Set WordPress Post Title To The Category Name
- How to find out if an wp-admin action edited a file?
- Text snippets shared across posts
- Add Admin User via SQL
- Add number new posts (post_status = pending) to administration menu [duplicate]
- How to remove Gravatar from Username column
- Page only shows when user is logged in (even with visibility set to public)
- I keep getting logged out in Firefox
- get_template_part in admin
- Why Jetpack is missing the “Feedbacks” menu item? [closed]
- Getting the different post statuses + count like in edit.php, in a custom submenu page
- What is the optimal way to filter out subpages from admin?
- Create a Meta Box in the Admin User Screen?
- Send email to Admin when user/member updates specific user/member data
- Help with shortcode in admin-ajax [closed]
- Protect custom php file with login
- disable admin-bar search field for specific roles
- Limit Words in Category / Term Description – Admin Panel
- Change top level menu item to point to custom submenu item
- Change admin logout URL
- Link to post author but exclude administrator (on single.php)
- Default admin color scheme as “blue”
- Can user #1 (the initial user) be deleted without ill effect?
- wp-admin post.php JavaScript Links Not Working
- When admin changes a password for a registered user, I don’t want to send a password change email to users
- How do you handle postmeta in admin area?
- Admin – Load existing admin template as a submenu page
- Admin interface problems – thickbox? jquery?
- Restricting access to a single MultiSite site based on IP — possible?
- admin : search custom fields
- Admin cannot publish
- Activate Gallery Options in Media Uploader for Custom Usage
- Get post attached image to display in admin dashboard
- How Can I Found Admin Directory
- Combine and Minify wp-admin files, also re-write URI’s for CDN
- How to disable accessing the custom post types from frontend via a link?
- Problem with Settings API: changes are not saved after submit
- Show excerpt if no title in admin view
- hide default post body field in backend
- How to make the first widget box to be closed instead of open in admin
- Change default italic from to in admin editor
- Can I host WP-admin locally for a remote blog?
- add_cap for editor but no admin role
- WordPress Home/Front Page Display at top of Admin Pages List
- Bind custom role to admin page
- /wp-admin/install.php redirecting to 123-reg
- Home page is redirecting to another page – no obvious reason
- Backend Checkboxes working – but not visual?
- Why does Thickbox jQuery load on my site?
- Redirect admin 403 “Cheatin uh?” admin pages
- iframe with Youtube video appears for logged-in users, but not for incognito users
- Admin mode breaks with subdomains in latest WP
- How do I create a post_id column, for admin posts list?
- Custom Jquery in admin breaks media-upload script
- How should I change the username of or delete the admin user?
- Prevent Registration Where Role is None?
- Extending the user profile [closed]
- Show private pages in public when you logged in as admin?
- Any known plugins for master admin login to edit all on front end?
- How to exclude some post from admin edit screen
- How to show WordPress admin dashboard forms on front-end?
- Allow custom REST route to return before doing long operation
- WordPress – add help text under category list(right side) in post edit page
- Cannot access wp-admin after installing SSL – user capabilities not being set
- Where to store publicly-accessible files
- Show only content in page after action click in WordPress admin
- WordPress4.1.15 Dashboard links not working
- Admins loggin in to our wordpress site default to the admin page
- Display Graphs in Admin Pages
- ‘Conflict’ with action deleted_post and is_admin()
- Dropdown list of available posts for post editing
- Unsure how to add simple checkboxes that write to a small table to admin
- Custom styles and scripts for specific admin screen
- Add Sort Link in Custom Post Type List
- local WAMP admin user has lost privileges
- Is it possible to get rid of admin new updates notifications?
- WordPress 4.5 Inline Link Toolbar not working on custom wp_editor instance
- Cant enter admin page with SSL