13 Responses

  1. Rarst
    Rarst July 12, 2011 at 3:32 pm |

    Why admin_head-$hook_suffix rather than admin_print_styles-$hook_suffix and admin_print_scripts-$hook_suffix? It doesn’t matter much all of these next to each other, but latter seem more semantically fitting as for me.

    Reply
  2. The Frosty
    The Frosty July 12, 2011 at 3:34 pm |

    Now if everyone would just add-hear.

    Reply
  3. Theo
    Theo July 12, 2011 at 4:48 pm |

    Well, this is great stuff, especially as you can apply it for custom stylesheets too.

    Reply
  4. R.Bhavesh
    R.Bhavesh July 14, 2011 at 12:26 am |

    Thanks very much for this tutorial Justin. This will really come handy and help us build better themes.

    Absolutely love the tutorials in here.

    Reply
  5. onioneye
    onioneye July 14, 2011 at 1:15 pm |

    Up until now, I was printing my scripts and stylesheets on every admin page. *turns his head towards the wall of shame*

    Reply
  6. L’Hebdo WordPress : Enquête WordPress – iPhone – +1 | Choisir-son-CMS.tk
  7. Daniel Roch
    Daniel Roch July 20, 2011 at 9:29 am |

    Many developers forget to use the right function to add content in the head section of a wordpress theme. Your code is great, but i have doubts that many people would use it in the admin side of a WordPress blog…

    Reply
  8. Link-urile lunii iulie | Staicu Ionuţ-Bogdan
  9. Shawn
    Shawn November 9, 2011 at 3:07 pm |

    What if you need a script to load for multiple admin pages, but still not all. For instance, if I am using a metabox option to upload images for use within a post-type, and I only want the javascript to load for that particular post type, what would the process be?

    The script would need to be available in the “post-new.php?post_type=XXX” and also in the “post.php” for editing the post.

    Would it be best to use multiple hooks such as :

    $post_page = ‘post-new.php?post_type=XXXX’;
    $post_edit_page = ‘post.php’;

    Doesn’t seem to be a way to specify post type on edit pages…

    Reply
  10. Dear theme developers, this is how you add scripts in WordPress themes | WPCandy
  11. Torstein Opperud
    Torstein Opperud September 5, 2012 at 6:05 pm |

    Ah, nice! This was just what I was looking for! I want to include a small google-map in a custom post types editor-pages, and I’d prefer to do it the right way! Thanks Justin!

    Reply
  12. Larry Bradshaw
    Larry Bradshaw January 28, 2013 at 2:01 pm |

    Is there anyway to editing an existing theme to remove the call from the Admin if it’s not needed at all? What files and what could would need to be commented out?

    Reply

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.