How to Use JSON With AJAX?

Usually, you can use the global variable ajaxurl instead of any path using admin-ajax.php. More importantly, the PHP function should echo the response before calling wp_die(). Because you haven’t called wp_die(), AJAX is probably waiting for more from PHP. Hope this helps. P.S. What is that ‘json’ string doing where the AJAX fail() function should … Read more

How to hide a specific user role option in a user role list?

SOLUTION: // Remove Administrator role from roles list add_action( ‘editable_roles’ , ‘hide_adminstrator_editable_roles’ ); function hide_adminstrator_editable_roles( $roles ){ if ( isset( $roles[‘administrator’] ) && !current_user_can(‘level_10’) ){ unset( $roles[‘administrator’] ); } return $roles; }

How to get new post URL?

admin_url(‘post-new.php’); The admin_url function will handle generating most of the link, you just need to give it the final component. You can pass in GET parameters as well. Just look at the backend URL to see what you need. admin_url(‘post-new.php?post_type=page’); Or using add_query_arg as suggested by @Rarst … add_query_arg(array(‘post_type’=>’page’),admin_url(‘post-new.php’)); It is overkill for simple URLs … Read more

Why does this Quick Edit checkbox save the value only when unchecked?

Why the headline_news meta data is deleted on the Edit Post screen, with a fix The qedit_save_post() function stomps on headline_news because $_POST[‘headline_news’] is not set when using the post edit screen. Since the custom fields editor is being used for headline_news and there is no custom meta box involved, we’ll let the built-in custom … Read more

How to Remove Checkbox for Excerpt Under Screen Options

You can do this with CSS. .metabox-prefs label[for=”postexcerpt-hide”] { display: none; } In regard to adding the CSS to the admin section, you have two options: Option 1: Add the CSS to a stylesheet and enqueue it using the admin_enqueue_scripts hook. function load_custom_wp_admin_style() { wp_register_style( ‘custom_wp_admin_css’, get_template_directory_uri() . ‘/admin-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom_wp_admin_css’ ); … Read more