Tag Info

Hot answers tagged

1

There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is to hook into admin_enqueue_scripts and use the $hook parameter: add_action('admin_enqueue_scripts', 'cyb_admin_scripts'); function cyb_admin_scripts( $hook ) { //You may need adjustment here to match for page //If the URL of your page is ...


1

While front–end of the site always has a post context (you are either looking at one or archive of posts), admin side doesn't. So plenty of admin screens won't have $post global set to anything. You should be checking if it's meaningful (for example by if ( ! empty( $post ) )) before trying to access it.


1

You're going to have to use the filters for each post type anyway. If you plan to leverage a bunch of dynamic filters that all call for all 7 post type slugs you could stick them in an array and loop through the filters with a foreach. Saves a little bit of code at least. $post_types = array( 'ptype_one', 'ptype_two', 'ptype_three', 'ptype_four', ...


1

You can try this one: /** * Fires as an admin screen or script is being initialized. * * Note, this does not just run on user-facing admin screens. * It runs on admin-ajax.php and admin-post.php as well. * * This is roughly analgous to the more general 'init' hook, which fires earlier. * * @since 2.5.0 */ do_action( 'admin_init' ); if you need ...



Only top voted, non community-wiki answers of a minimum length are eligible