Load a script just to custom post type in admin

Try this code for adding scripts to the edit pages of your portfolio custom post type. add_action( ‘admin_print_scripts-post-new.php’, ‘portfolio_admin_script’, 11 ); add_action( ‘admin_print_scripts-post.php’, ‘portfolio_admin_script’, 11 ); function portfolio_admin_script() { global $post_type; if( ‘portfolio’ == $post_type ) wp_enqueue_script( ‘portfolio-admin-script’, get_stylesheet_directory_uri() . ‘/admin.js’ ); }

how to know if admin is in edit page or post [duplicate]

You can use get_current_screen to determine this. $screen = get_current_screen(); if ( $screen->parent_base == ‘edit’ ) { echo ‘edit screen’; } I don’t know if I exactly would say this is always better, it depends on what’s needed, but it’s probably the way I’d do it. The big benefit with this method is that you … Read more

Add a Separator to the Admin Menu?

Here’s a quick and dirty way to get what you want. Background WordPress stores admin menu sections in a global array called $menu. To add a separator you add an element to the $menu array using an index that is between the indexes of the options that you want to separate. Using the add_admin_menu_separator() function … Read more

wp_verify_nonce vs check_admin_referer

I thought that check_admin_referer checked the nonce (it does call wp_verify_nonce, and the referring url. After digging into the core code I realised that it did not do this. Thinking it was a bug I reported it, and Ryan Boren replied with the following: Actually, if the nonce is valid the referrer should not be … Read more

Changing the Order of Admin Menu Sections?

Hi @BinaryBit: It’s no wonder you are a bit frustrated; the admin menu is one of the most obtuse and frustrating implementations through WordPress core. Honestly, I don’t know what they were thinking when they designed it that way. @EAMann did an excellent job of explaining how the admin menus work in WordPress (I wish … Read more

Add custom column to Users admin panel

Ok, Here is the code to allow your users to add phone numbers. Paste this full code in functions.php file. This will add new field on user profile for “Phone Number” and add a column user table on WordPress admin for phone. function new_contact_methods( $contactmethods ) { $contactmethods[‘phone’] = ‘Phone Number’; return $contactmethods; } add_filter( … Read more

How to remove admin menu pages inserted by plugins?

You need to use the right hooks (which are not always the same as the URLs/slugs), and it doesn’t hurt to use a hook that runs later (e.g., admin_init): add_action( ‘admin_init’, ‘wpse_136058_remove_menu_pages’ ); function wpse_136058_remove_menu_pages() { remove_menu_page( ‘edit.php?post_type=acf’ ); remove_menu_page( ‘wpcf7’ ); } You can use the following to debug: add_action( ‘admin_init’, ‘wpse_136058_debug_admin_menu’ ); function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)