If you want to perform any redirects, you have to send your header before site sends any output.
admin_head is an action that allows you to print your custom code inside <head> tag of admin sites. But if it’s inside of <head>, then some output is already sent to the browser, so you can’t perform any redirections any more.
As you can see here Actions Run During an Admin Page Request, the admin_head is called after the scripts and styles are already printed.
So you should run your code using some hook that is fired before any output is sent to the browser. You can use wp hook for example.
PS. Another thing is that you shouldn’t use header( "Location: admin.php?page=my-page&saved=1" );. Using wp_redirect would be much nicer way to do this.
Related Posts:
- the_date() not working
- Query multiple custom post types in single loop
- How to search display_name column when using WP_User_Query
- wpdb::prepare was called incorrectly
- Using WP_Query – how to display something IF there are no results
- How to order WP_User_Query results to match the order of an array of user IDs?
- I can’t fetch query parameters ($_GET parameters) with get_query_var
- How to order posts by modified date without using ‘query_posts’?
- Delete post revisions on post publish
- How to sort results from a custom database table
- Specific Loop For 2 Within Each
- Use two WP Query in template
- my function doesn’t return my post from today
- Display related products with custom output
- Get ID of child from child slug, while knowing parent ID
- spliting posts into two columns
- WordPress – query 5 posts with a specific post in top
- Multiple choice in a custom taxonomy
- Why is variable not working on custom sql query using wpdb?
- How to get a list of all possible values of a specific user meta key?
- Get stock by custom meta field on all Woocommerce variable products
- Any possible way to make $wpdb->get_results() return anything else than array?
- Custom filter in admin edit custom post type responding with invalid post type?
- Accessing the database from a plugin outside of action hooks
- Echo a hierarchical list of post data from custom fields
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Storing Array from returned database query and using the array in a new query
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- Set WP_query ‘order’ option by another tables value
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Increase offset while looping
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- Query if audio attachment AND/OR custom field
- register_taxonomy() take much queries
- WordPress SQL injection
- Odd / Even posts add class minus first post
- unable to use ‘new WP_Query’ in AJAX call
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to add div blocks after certain set of post
- working with term_relationships table
- WordPress query undefined offset in loop
- Can I make get_users() query global?
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- Issue with custom loop in Archive page
- Parse error: syntax error, unexpected ‘}’ [closed]
- PHP -> SQL Query with Summing
- How to hide posts of a specific custom category in WordPress?
- WordPress PHP syntax doesn’t seem to be working correctly
- How to get thumbnail with pure PHP in a WordPress database?
- mySQL queries are executed twice on wordpress website
- Echo array value
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Query pulling a single post per month
- WordPress Custom Query: Combining Two Functions
- SQL error with custom query
- WordPress Conditional / Multiple Taxonomy Query
- How can I modify this code to make the search box include tags and meta
- Reject all malicious URL requests functions.php
- Advanced Query posts
- How can I check that the acf field value is not a duplicate when adding a post?
- My Custom Post Type AJAX Query is Returning no posts – why?
- array wordpress when get is null
- getting the values of hidden inputs to use them in a php mysql query
- Offset with ajax load more posts duplicates
- Query doesn’t display text data with apostrophes
- How to query a staging database?
- How to make a parent page for author.php?
- Pagination in WP Queries
- Include a custom field in mysql query
- Echo multiple tasks if a common function exists
- How to enqueue assets only on queried pages, excluding the page being queried?
- “Where… like” query not working as expected
- Unserializeing multiple column values that are stored in one database results variable
- Problems With Query and/or Template Part and/or PHP
- If Elseif Query
- Arrange Category post manually when displayed
- How to callback custom field text
- How can I add more code to this?
- The search engine of my website finds only posts and not pages, how can I solve this problem?
- Does wp_query and query_posts affect website performance? [duplicate]
- Hide empty categories from get_categories
- How to insert a variable into a query parameter?
- wp_query on search results page showing all results every time
- WP_Query not returning results
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- Sorting a custom post type in pre_get_posts
- Three different queries on same page
- SQL query to retrieve the number of WordPress posts with all given categories
- Exclude a category ID from the following function
- Custom Filtering date with newsletter
- Pre_get_comments and orderby comment_karma
- Display featured posts first, then display all others within a specific category in WordPress
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- How to allow searching a custom meta key in admin list table?