How can I add Javascript in the header of all post pages and only post pages

Check the type of the queried object on the page and the post type: function function_that_returns_js_string() { $obj = get_queried_object(); $type = is_a($obj,’WP_Post’); if (true === $type && ‘post’ == $obj->post_type) { echo ‘your string’; } } add_action(‘wp_head’, ‘function_that_returns_js_string’); However, I am concerned that you are inserting a script directly into the head of the … Read more

Easy popups for wordpress?

WordPress bundles a ThickBox library, which can be queued from its core. However it doesn’t quite bother to make external reuse easy (not that it’s overly complicated though). Notably ThickBox is very old. Depending on your specific requirements it might be preferable to choose a newer library and ship it with your own code (license … Read more

How to open the add media dialogue it in a certain state / tab?

Suppose you want to open the modal to the create gallery section: var options = { frame: ‘post’, state: ‘gallery’, title: wp.media.view.l10n.createGalleryTitle, multiple: true }; var frame = wp.media.editor.open(null,options) If you want something else, I suggest you search through the core js source to change the Library ID as appropriate for the section you need.