
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.

I'd like to reuse these functions in some other pages. I have a WordPress page that has a script with a few functions and then another short script that uses them. Will appreciate a few lines of concrete instructions. The default height is way to big and so the other meta boxes on this CPT are pushed down the page. I'm new to WordPress, tried first searching for this and found a few related answers, none of which i fully understood. 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 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). order to load the scripts and stylsheets conditionally only on the admin pages. We simply create a PHP script with a specific block comment at the top of the page, more details on this can be found on the WP Plugins handbook page. I really wish I had looked into them sooner, they are so cool. The enqueue script function is there so that the WordPress core and the. Normally, plugins use wpenqueuescripts hook to enqueue scripts, but here we use a dynamic hook so that chart scripts are added only to plugins admin. I’ve finally(!) got around to using custom post types, and I’m having a blast.

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