Title: 3.0b1 custom post types and javascript
Last modified: August 19, 2016

---

# 3.0b1 custom post types and javascript

 *  [jonlb01](https://wordpress.org/support/users/jonlb01/)
 * (@jonlb01)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/30b1-custom-post-types-and-javascript/)
 * I was wondering if anyone knew how to include custom Javascript in the write 
   panels for a custom post type. I’ve been able to get the custom post type working
   for the most part but need a little custom javascript magic for a few pieces.
   I’d like to be able to include it via a script tag in the header if at all possible.
 * I’ve tried searching through the forums and haven’t been able to come up with
   anything.
 * Thanks,
    Jon

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Wimsito](https://wordpress.org/support/users/wimsito/)
 * (@wimsito)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/30b1-custom-post-types-and-javascript/#post-1460727)
 * Hello,
 * As far as I can see their is no clean way in 3.0b1 of doing this, but I’m not
   really a plugin/wordpress expert nor do I develop much.. Probably a more experienced
   developer could come up with a cleaner solution, but untill then you could use
   this :
 * Around the same line where you call the admin init hook you do
    `add_action("
   admin_enqueue_scripts",array(&$this,"testaddjs"));`
 * (I’m assuming you’re using a plugin with class here)
 * In your pluginclass you put the function
 *     ```
       function testaddjs($hook_suffix) {
       	global $typenow;
       	if ($typenow=="songtekst") {
       		echo "<script src='../wp-content/plugins/test.js' type='text/javascript'></script>";
       	}
       }
       ```
   
 * where “songtekst” is your custom taxonomy’s slug. (for reference, hook_suffix
   is the page called, like post-new.php, and typenow is the post_type parameter
   in the url.
 * Good luck!
 * Edit : Interesting links :
    [3.0b1 /wp-admin/admin.php in svn](http://svn.automattic.com/wordpress/trunk/wp-admin/admin.php)
   [admin_enqueue_scripts as a 2.9 hook](http://adambrown.info/p/wp_hooks/hook/admin_enqueue_scripts?version=2.9&file=wp-admin/admin-header.php)
   [add_action in the Codex Function Reference](http://codex.wordpress.org/Function_Reference/add_action)
 *  [Josh Leuze](https://wordpress.org/support/users/jleuze/)
 * (@jleuze)
 * [16 years ago](https://wordpress.org/support/topic/30b1-custom-post-types-and-javascript/#post-1460959)
 * Thanks so much for sharing this solution Wimsito.
 * I have been trying to do something similar, add CSS to the admin pages for just
   the a custom post type, and the code worked perfectly for that.
 * It is surprisingly easy to create a custom post type with a plugin, but tough
   to add a settings menu, icons, and other things to really customize that new 
   post type.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘3.0b1 custom post types and javascript’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
 * 2 replies
 * 3 participants
 * Last reply from: [Josh Leuze](https://wordpress.org/support/users/jleuze/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/30b1-custom-post-types-and-javascript/#post-1460959)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
