Is there a hook I can use that when a post is created or updated it goes back to the list/table page of all the posts. If it is also possible to target a post type as well that would be cracking.
It’s a really silly request I know and have argued the toss about it but wanted to make sure it was achievable if not very user friendly.
Steve
Use the
redirect_post_location
filter andadmin_url()
function.To redirect to a different url, add everything after the
/wp-admin/
portion of the url. I used"edit.php"
because the intended url was:http://example.com/wordpress/wp-admin/edit.php
.The
redirect_post_location
filter is not documented in the Codex Filter Reference. You can find it in thewp-adminpost.php
file near line 73. This is the WordPress code in the trunk version of WordPress:As you can see, you can also test the
$post_id
redirect based on the$post_id
or any information obtained from it. To use this second parameter of the filter, you need to pass the priority and _accepted_args_ parameters in the filter call:And update the function parameters: