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
- What is the best practice for escaping data URIs?
- How do I get the author’s page url from their ID?
- How to use a frontend URL with a Plugin
- WordPress template_include filter not working properly
- Add filename to attachment page url
- “The plugin generated 2694 characters of unexpected output…” on Plugin activation, CREATE TABLE sql command not working
- How to display a value from a radio button in the options menu in wordpress
- How to access function from outside of a class within this class in WP plugin?
- How to call function at the bottom of post using plugin?
- Echo URL of large version of Featured Image
- WP add_action factory
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to show phpinfo() only in a new tab?
- How can I remove a function that has been added to wordpress with add_filter?
- Changes in permalink structure in WordPress and how to apply to in-site links
- How to change redirection route to a php page for making it only accessible by logged-in members?
- WP CRON duplicate wp_insert_post with has < and > tag
- How to insert data into database using wp cron job
- How to send Ajax request from my plugin in admin dashboard?
- AJAX success response is not working but it’s saving my changes
- Perform internal redirect in WordPress?
- Best practice for show data to one specific user?
- Get URL Parameters from referer
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Asynchronous multiple requests 401 Unauthorized
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Using data sent via AJAX in multiple functions on a WP plugin
- What does -> mean in WordPress?
- How to add the sidebar to all the pages except the home page? [closed]
- WordPress shortcode returns the data before
- Plugin development and composer
- Set default Database Storage Engine when creating tables with plugins?
- Remove slugs from custom posts type
- .html end of URl affected to SEO?
- custom post type with role Vendor
- Call featured image url
- Execute Jquery when a specific page in my plugin is loading
- Use an anchor link to open an iframe inside a WordPress page
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- WordPress can’t use ZipArchive
- Settings API form – submit with AJAX
- How to change basename url for wp-admin?
- url not using query string no longer working
- Only the first image uploads
- WordPress loading progess – wp-blog-header.php
- Illegal string offset checkbox
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Trying to use a variable to set image width
- wp_update_post gives 500 internal error
- Current WordPress Page Title as Search Parameter into A Tag
- How to identify which php file a plugin is using on page load?
- dashboard widget form not submit mails
- register_setting not save checkbox
- Permalink doesn’t navigate to post (changes only url)
- How to edit button permalink inside function.php using a child theme?
- How to give custom roles the capability to edit one Menu instead of every Menu
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- add menu page in loop menu order
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Private messaging – Getting and displaying the avatar/url of a message recipient
- changing static link to relative link
- Permalinks and custom PHP application
- widget: input the px value from user and use it as inline style in widget function
- Create a dynamic buddupress tab
- Custom post type single page return to listing page
- Would it be possible to route WordPress Through an MVC Application
- WordPress rewrite question
- Using Nonce for my Form
- Create new folder and upload files to custom folder via wp_handle_upload
- SHARING TO FACEBOOK – FROM DYNAMICALLY GENERATED PAGE
- PHP code for link with text
- Custom field fetch error on woocommerce pdf invoice
- Implement OAuth2 in custom plugin
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to pass and validate nonce in custom REST routes
- How to lock users account until approvation
- How can I change the URL via add_rewrite_rule()
- Variable ++ in query loop
- why css file not link?how to create permalink?
- ajax problems on loading page [closed]
- WordPress REST API – Custom field not added to pages