How can I identify it as admin page or not?
-
26-04-2021 - |
質問
I only want to display it on all pages without the admin pages. How can? How to detect is it admin page or not?
My custom plugin file: ~/wp-content/plugins/mycplugin/mycplugin.php
if ( not admin page ) { // ?
if ( defined ( 'WP_AUTO_UPDATE_CORE' ) ) {
print '<div style="background-color: black; bottom: 0; color: white; font-family: monospace; font-size: 10px; opacity: 0.5; padding: 0.5em; position: fixed; width: 100%;">' . WP_AUTO_UPDATE_CORE . '</div>';
} else {}
} else {}
解決
Use is_admin()
function. It will return true if it's wp-admin page and false on frontend.
more here https://developer.wordpress.org/reference/functions/is_admin/
所属していません wordpress.stackexchange