36 votes

Load a script just to custom post type in admin

I'll post a better solution because the accepted answer is old and does not use the right hooks. First of all: To enqueue scripts and styles in admin area, must be used admin_enqueue_scripts and ...
Andrei Surdu's user avatar
33 votes
Accepted

The website cannot display the page

I fixed it!!! Woohoo. Using this link - link to patch I edited the line it advises and it works fine.
Silentbob's user avatar
  • 541
25 votes

how to know if admin is in edit page or post

Better way: global variable $pagenow global $pagenow; if (( $pagenow == 'post.php' ) || (get_post_type() == 'post')) { // editing a page } if ($pagenow == 'profile.php') { // editing ...
T.Todua's user avatar
  • 5,789
22 votes
Accepted

How can I send data to admin-ajax via JS Fetch?

Is it proper way to pass the data in the form like I did? If you mean the body part (of your fetch() call), then yes, it is okay. However, You must send a query named action as part of the request (...
Sally CJ's user avatar
  • 39.1k
20 votes
Accepted

Remove update nags for non-admins

In wp-admin/includes/update.php file if ( current_user_can('update_core') ) $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the ...
bravokeyl's user avatar
  • 3,349
19 votes
Accepted

How to pass parameters to admin_notices?

I think a better implementation would be a "message" class e.g.: class WPSE_224485_Message { private $_message; function __construct( $message ) { $this->_message = $message; ...
TheDeadMedic's user avatar
  • 36.4k
17 votes
Accepted

Multiple custom post types under one admin menu

Just create a "placeholder" menu that you can then assign all your post types to: function wpse_226690_admin_menu() { add_menu_page( 'Events Manager', 'Events Manager', '...
TheDeadMedic's user avatar
  • 36.4k
15 votes

Disable SSL / HTTPS for wordpress

Check your wp-config.php file for lines like: define( 'WP_SITEURL', 'https://example.com' ); define( 'WP_HOME', 'https://example.com' ); Also check your database's {prefix}_options table: SELECT ...
Pat J's user avatar
  • 11.8k
14 votes
Accepted

Custom CSS In Admin Only For Certain Roles

Upon request I will write an answer using a function from a suggested answer for the similar question: How to target with css, admin elements according to user role level?. This function will output ...
JHoffmann's user avatar
  • 1,830
12 votes

What is the real intention for admin-post.php?

admin-post.php is like a poor mans controller for handling requests. It's useful in the sense that you don't need to process your request on an alternative hook such as init and check to see whether ...
Adam's user avatar
  • 16.4k
11 votes
Accepted

How to Add a Third Level Sub Menu to the Wordpress Admin Menu

No, it is not possible to create third level menu in admin panel. If you look at the definition of add_submenu_page, you need to mention the parent slug name. For eg: add_menu_page ( 'Test Menu', '...
Karthikeyani Srijish's user avatar
10 votes

current_user_can('Administrator') does not return true in multisite if user is Administrator but NOT Super Admin

There is a Typo in your expression use current_user_can('administrator') instead of current_user_can('Administrator') (a instead of A).
dvp's user avatar
  • 101
10 votes
Accepted

wp.template() Not a function

Ah, I get it. When you enqueue your admin script, add 'wp-util' as a dependancy. wp_enqueue_script( 'script_handle', plugin_dir_url( __FILE__ ) . 'script.js', array( 'jquery', 'wp-util' ), '1.0',...
Justin W Hall's user avatar
10 votes
Accepted

How to remove items from +New admin menu?

To hide everything (menu and submenu)- function wpse_260669_remove_new_content(){ global $wp_admin_bar; $wp_admin_bar->remove_menu( 'new-content' ); } add_action( '...
mukto90's user avatar
  • 1,344
9 votes

if admin is logged in

It seems that the simplest way would in fact be to use current_user_can as such: if( current_user_can( 'administrator' ) ){} // only if administrator This seems like a duplicate.
Adal's user avatar
  • 279
9 votes

Can you have the users list pre sorted by specific column?

This code will add the sortable user registration date column and it will handle default sorting of the user table by registration date. The majority of this code was taken from Mika Epstein's ...
Dave Romsey's user avatar
  • 17.7k
9 votes

How to enable Admins to see Plugins

Have a look at the Network Admin Settings screen (in my installation, it's at example.com/wp-admin/network/settings.php). Tucked away down near the bottom is this: Menu Settings Enable ...
Pat J's user avatar
  • 11.8k
9 votes

turn off new user registration emails

Approach for WordPress 4.6+ Check out the patch in ticket #36009 that was merged into WordPress version 4.6. It adds the 'user' option for the $notify input parameter of wp_new_user_notification(), ...
birgire's user avatar
  • 67.1k
9 votes
Accepted

Stop admin-ajax?

The first thing admin-ajax.php does is define DOING_AJAX. Then, it loads wp-load.php. It does some other stuff, and the first thing it comes across that you have control over is wp-config.php. So if ...
Nathan Johnson's user avatar
9 votes
Accepted

Where is custom template file chosen for a post stored in the DB?

It's in the post meta table (usually wp_postmeta), with the page id in post_id, meta_key with _wp_page_template and meta_value with the template file name.
Felipe Elia's user avatar
9 votes
Accepted

Custom WP_List_Table displays blank rows

You're getting the blank rows because your column headers are registered late. And you should register the headers (i.e. initialize the list table class instance) before admin notices are rendered on ...
Sally CJ's user avatar
  • 39.1k
8 votes

wp_verify_nonce vs check_admin_referer

NO! BEWARE !!! Don't count on check_admin_referer() without correct parameters! Because, in some cases it may not die() (as opposed to your expectations), instead it will just return the false ...
T.Todua's user avatar
  • 5,789
8 votes

Permalinks Question: Adding a prefix ONLY in front of the posts

1) Add this rewrite at the end of you function.php function add_rewrite_rules( $wp_rewrite ) { $new_rules = array( 'YOUR_PREFIX/(.+?)/?$' => 'index.php?post_type=post&name='. $...
Fury's user avatar
  • 181
8 votes
Accepted

Disable WP Editor for specific page templates

Yes, try this : function remove_editor() { if (isset($_GET['post'])) { $id = $_GET['post']; $template = get_post_meta($id, '_wp_page_template', true); switch ($template) { ...
user6552940's user avatar
7 votes

How does admin-ajax.php work?

For unauthenticated and untrusted users, you'll want to make two specific exceptions to your VPN / Firewall / Apache .htaccess, which are: example.com/wp-admin/admin-post.php example.com/wp-admin/...
haz's user avatar
  • 630
7 votes

how to know if admin is in edit page or post

Use 'get_current_screen', just make sure beforehand, it exists. As codex says "This function is defined on most admin pages, but not all." This btw also filters out normal (reader-facing) views (re-...
Frank N's user avatar
  • 455
7 votes

Appearance->Editor not visible

I had a similar problem (albeit 3 years later) and after some research I had a process for potentially identifying the source of the problem and subsequently found that my issue was hidden in a plugin ...
WPDavid's user avatar
  • 199
7 votes
Accepted

A similar hook as wp_head for the admin area

The alternative to wp_head action in admin area is admin_head. But, if your CSS depends on another stylesheet, you should use wp_add_inline_style() function hooked to admin_enqueue_scripts action.
cybmeta's user avatar
  • 20.5k
7 votes

How to add post_author column to custom post type

The $supports argument should include author for the Author settings to be available for the custom post type: 'supports' => array( 'title', 'custom-fields', 'author' ) 'supports' (...
Dave Romsey's user avatar
  • 17.7k
7 votes

Disable SSL / HTTPS for wordpress

You can modify .htaccess file: RewriteEngine On RewriteCond %{HTTPS} on RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
user113337's user avatar

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