psychicqert.blogg.se

Wordpress enqueue script on specific admin page
Wordpress enqueue script on specific admin page







So I created a wrapper function for wp_enqueue_style() that you can use to pass your CPT name along with the usual enqueue parameters, and it will magically enqueue your style ONLY on the CPT editor page that you specify! Cool huh?įirst off, let’s target the general admin editor pages to run a callback function when either the post.php or post-new.php are loaded. After a bit of experimentation I came up with a solution that I could probably reuse. So, I spent some time looking for a reasonable way that I could enqueue styles that would work for specific CPT’s. However this has the side effect of altering the post editor for ALL post types. The solution? Well, it is fairly easy to add custom CSS that will target just the post.php or post-new.php pages in the WordPress admin. The default height is way to big and so the other meta boxes on this CPT are pushed down the page.

wordpress enqueue script on specific admin page

and a few admin pages, created with and How do I load my two function. For the login screen, use the loginenqueuescripts action hook. To call it on the administration screens, use the adminenqueuescripts action hook. order to load the scripts and stylsheets conditionally only on the admin pages. I have two simple functions that load stuff using and, something like these. The function should be called using the wpenqueuescripts action hook if you want to call it on the front-end of the site, like in the examples above. The editor for the CPT in question is only ever going to be used to enter a couple of sentences, so it really only needs to have a small height. The enqueue script function is there so that the WordPress core and the. How do I Enqueue styles/scripts on Certain /wp-admin Pages I have two simple functions that load stuff using wpenqueuestyle() and wpenqueuescript(). The possibilities really are endless, and boost the capabilities of WordPress significantly.Īnyway, this post is about an interesting problem I ran into whilst creating my first CPT (custom post type).

wordpress enqueue script on specific admin page

I really wish I had looked into them sooner, they are so cool. I’ve finally(!) got around to using custom post types, and I’m having a blast.

wordpress enqueue script on specific admin page

Category: Featured, WordPress 3.x Tags: CPT, editor, enqueue, scripts, styles









Wordpress enqueue script on specific admin page