Cannot add style in wp_head if inside another function
-
// Function to add styles in the admin header only for plugin page add_action('admin_head', 'abc'); function abc() { global $pagenow; // Check if the current page is your plugin's settings page if ($pagenow === 'admin.php' && isset($_GET['page']) && $_GET['page'] === 'my-slug') { echo "work so good"; } } // Render plugin settings page function my-plugin-page-settings() { // Adding scripts/styles in the admin head for this page add_action('admin_head', function() { echo 'not work at all'; }); // Adding scripts/styles in the admin footer for this page add_action('admin_footer', function() { echo 'work so good'; }); }
So, i need to filter via global pagenow, cause not work if inside my plugin page function (but here, indeed, work so good admin_footer).
someone can help me to best understood?
- Il topic ‘Cannot add style in wp_head if inside another function’ è chiuso a nuove risposte.