Working in the admin is quite a bit different from the front-end of a WordPress site. Most of the documentation you’ll find online deals solely with the front-end. That can be frustrating when looking for something that should be simple and straightforward.
In this case, I think you would use get_current_screen()
. This returns the screen’s ID, action, base, and other features of the admin page.
From the codex on get_current_screen()
:
This function returns an object that includes the screen’s ID, base,
post type, and taxonomy, among other data points
This doesn’t work everywhere in the admin, so make sure you read the restrictions.
Related Posts:
- How to get URL of current page displayed?
- Dynamic URL to reference custom PHP files
- How is WordPress manipulating the posts like there are folders?
- Extend PHP regex to cover “srcset” and “style” attributes
- Create custom permalinks to show Custom Post Type’s relationship?
- Change product_base programmatically
- WordPress permalink issue
- Allow two posts (from different categories) to have the same slug
- Rewrite rule not working, but only when parameter is text
- Get WordPress username to customize url
- WordPress/NGINX not respecting the category URL for new posts
- How does one make a URL return dynamic JSON with custom Content Type?
- How do I generate formatted permalinks as specified in backend options?
- Remove /category/ from category (archive) page URLs (without using a plugin)
- How to extract URLs from wordpress taxonomies
- Create a custom plugin with dynamic child pages listing database records
- Remove slug of multiple custom post types with and without hierarchical
- change the blog in the url if you go from a specific page wordpress
- Custom plugin with dynamic child pages listing database records
- Insert array data on plugin activation
- Will simple function names in a class structure conflict with other plugins?
- Do my defines need to be unique?
- WordPress php filter admin_body_class not working
- Do changes to WordPress permalink custom structure affect old urls?
- Instantiate class to be available to all plugin functions
- Common abstract class for plugins
- Echo URL of large version of Featured Image
- Why does WordPress remove my variables in the URL?
- How to test nonce with AJAX – Plugin development
- What does $wpdb->get_row return?
- WP add_action factory
- wp_loaded hook block script enquequing
- WP nonce invalid
- woocommerce subscriptions – get expiration date [closed]
- Same log message keeps on printing to debug.log file thousand of times
- WordPress custom slug (endpoint) and compare all links
- Adding Default Settings to Theme My Login plugin
- Custom filter in admin edit custom post type responding with invalid post type?
- WordPress Scheduled Event Request Blocking
- How can i upload images in an admin page?
- Append HTML Using Shortcode
- Delete a WordPress transient from a shortcode on Page/Post update
- Plugin CSS not enqueing
- Create onClick Event to Re-load a Widget
- Swapping wp_dropdown_categories function with wp_category_checklist
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to show phpinfo() only in a new tab?
- How to find error in my code when the error message is pointing to WP core file?
- How to select the contents in the text view textrea in wp_editor?
- Add prefix to link url
- How to access global variable $menu inside a class function
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- How can I remove a function that has been added to wordpress with add_filter?
- 200 Rewrite blog post links
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to sanitize any integer input field in wordpress?
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- WordPress ajax doesn’t display object method on jQuery .change() function
- Custom user login page by creating a plugin
- php script to change slug in post automatically
- Singelton class does not work, multiple initialization on page reload
- Saving an array of dynamic repeater data as post_meta
- what is the best practice to add new field to an api route
- filter default query to show just selected level of child pages in wordpress
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- How to upload a file to a folder named after the user_id via plugin
- Reprinting tags with all attributes
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Dynamic content based on a URL parameter
- Use custom post type for a store locator
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- Improve page speed loading using CDN and async or defer attribute
- Colon is Missing In My Website Url in WordPress
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- How do I programmatically set a user as spam in BuddyPress? [closed]
- WordPress every page is 404 not found including admin resources
- How to change redirection route to a php page for making it only accessible by logged-in members?
- WordPress returning 404 for multisite pages
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- How to call plugin function per site in a multisite?
- Update results, Before deleting the related category [closed]
- How to make my custom widget appear within WordPress widgets? Plugin development
- Script to browser problem PHP
- adjust section according to country?
- How to auto fetch customer details in Woocommerce in checkout page
- Can’t upload image using media_sideload_image
- Store a default value for a transient on plugin activation
- Adding widgets to my plugin page instead of WordPress dashboard
- WP CRON duplicate wp_insert_post with has < and > tag
- How wp-cron can run in background if PHP is single threaded?
- How to insert data into database using wp cron job
- How to send Ajax request from my plugin in admin dashboard?
- I want to add custom add to cart link [closed]
- Options API get_option() and update_option() Not Correctly Updating or Returning