[wp-hackers] custom post type post editor add_action script targetting

Mark Duncan wp-t31os at ntlworld.com
Mon Nov 8 16:40:06 UTC 2010


Action for the edit posts(or whatever type) page..

  Scripts
  add_action( 'admin_print_scripts-edit.php', 'your_callback' );

  Styles
  add_action( 'admin_print_styles-edit.php', 'your_callback' );

Assuming you want to target only the post listing page (same hook 
applies for any post type).

For inside the function:

  global $typenow;
  if( 'your_post_type' == $typenow )
  // Do your enqueue

Hope thats what you're after.. ;)

On 08/11/2010 16:05, Philip M. Hofer (Frumph) wrote:
> I'm trying to target the edit page for a specific post type for
> add_action('admin_print_scripts-' .<location here>
>
> So that the scripts do not load on every admin page, unfortunately i'm
> just *not* getting it how to target that; I can do it using
> $_GET['page'] for *other* pages or even the hook for the
> add_submenu_page, unfortunately specifically the edit page gets
> generated from within core and no idea the hook.
>
> hrm.. should I do if ($post->post_type == '<posttypename>') ? but then
> it would hit some of the other admin pages when it shouldn't; $post gets
> generated with some defaults since its blank with the "add new posttype"
> page; blah.
>
> Any ideas?
>
> - Phil
>
>
> Also, var_dump($wp_query) of course is coming out null, so what would I
> use to check the created variables for those edit pages to see what I
> could use as a specific?
>
>
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



More information about the wp-hackers mailing list