There are two more possible ways
-
Use the browser’s history API to manipulate the URL displayed at the address bar/ history.
-
Use AJAX
Redirection is the best solution for 100% browser support and it is probably the easiest to implement. You don’t need to use any hook with that just do the processing without generating output and then redirect back to the page. Something like
if (isset($GET['posttodelete'])) {
delete post
wp_redirect(utl with 'posttodelete' stripped out of it);
} else
normal loop;
But your users might prefer the AJAX solution which requires much more coding but gives the best user experience.
Related Posts:
- Using action hooks inside of a shortcode
- Redirect users on specific post category or category page
- Enclosing Shortcode Within Another Enclosing Shortcode Breaks Output Functionality
- How can I collect and output all attributes of all executed ShortCodes?
- A good hook to check authorization and redirect?
- Which hook should be used to add an action containing a redirect?
- Redirect function inside a Shortcode
- Why are you using add_action for shortcode?
- How can I put a wp_redirect into a shortcode?
- Redirect logged in users if they are on a specific page
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- after login that will redirect user role into a page
- Pros and cons of actions over shortcodes
- template_redirect to accompany with a shortcode
- manipulate a plugins shortcode
- Print shortcode in custom action hook not where the shortcode is entered
- wp_redirect() not working on form submission with init hook
- Remove and restore one shortcode
- Firing a function AFTER redirect
- passing parameters to do action from shortcode to wp_footer
- Convert HTML Script to Shortcode [closed]
- How to redirect if a background request is still being executed
- Login form from shortcode doesn’t redirect after successful login
- How to wp_redirect on ‘init’ hook on condition of current post id?
- WordPress redirect redirecting too many times or not at all
- Redirect no product url’s to static url
- Use another action instead of the shortcode API to display the last time a user logged in
- redirect if shortcode exists
- Modifying the wordpress login page and then referencing it with a shortcode problem
- What hook to use to redirect based on $post
- contact form 7 :create shortcode usable in email message [closed]
- Set redirect for need login
- ‘Conflict’ with action deleted_post and is_admin()
- How to create shortcode for auto login after registration
- Members only Passthrough
- Add an access code form to call a unique page based on page without registration
- Cannot modify header information – headers already sent
- Hook into existing shortcodes to manipulate the attributes?
- What hook runs wpautop on template content?
- How to add site tags in alphabetical order to shortcode?
- How can i strip shortcode from HTML title tag?
- Can’t render shortcode when html tag contains hyphen
- Replace Data In Post & Update Meta Field Post Is Saved
- How to read and write session data?
- Adding shortcode of “Random Content” Plugin in the post after the title
- Shortcode won’t take into account custom post ID put in parameter
- How to redirect a child page to its parent page?
- Hook from plugin doesn’t fire up from external PHP script
- Bulk redirect all post
- WordPress multi domain: page redirect to main domain whenever WordPress do the URL guessing issue
- Action / Hook when a new plugin is added
- Can we change the hook firing sequence?
- changing genesis_before_while in new theme framework
- apply_filters() and call_user_func() to define and call a function outside a class
- Show content if user left comment / non-logged visitors?
- How to insert current user ID/entry ID into a shortcode?
- How to remove double quotes in a shortcode?
- Auto embeds don’t work for attachment descriptions
- Shortcode to appear and show the date not code in Title and description of my website
- Template not loading with get_template_part or locate_template
- Rewrite the search page to use an appended slug + parameter
- Session management issues with WordPRess 404 Error page
- Template_redirect works, but headers aren’t sent when checking via cURL
- Using `set_transient()` when saving a custom post type
- Shortcode to appear and show the date not code in Title and description of Social Media sites
- Need help with creating a simple shortcode
- Colon is Missing In My Website Url in WordPress Shortcode
- WordPress post shortcode pagination not working
- Wrap template code with shortcodes
- Applying ‘middleware’ to a url before redirecting? Does WP have built in mechanism for this?
- template_redirect hooks redirect wrong URL
- How can I prevent caching of wp_redirect?
- How to call do_action() to pass arguments to hooked functions that take different number of args?
- my form does not insert any data in the database
- Debugging issue with redirection in WordPress
- Using Shorcodes in Sharing Preview and Notifications Title from Post Title
- Not to escape a text
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- Add base folder to CPT and 301
- Using shortcodes in the Site Title
- Returning HTML to Shortcode Block
- WP REST API remove the WordPress shortcodes from the JSON wp/v2/posts content->rendered
- How do redirect user back to previous page when on certain pages?
- Use atributes of shortcode in get template part
- Global $post returns 2 objects for my shortcode
- How to display html element and php string in the same line?
- How to Display Shortcode’s Content after Short Product Description?
- Echo Extra Shortcode HTML to wp_foot
- How can I use a plugin shortcode inside of a html form?
- Gutenberg Shortcode Chooser Block
- How do I redirect the browser to 404 page, if no posts are found in home page
- Is there a way to know when a page has been updated and do some action only once?
- style_loader_tag not changing stylesheet to preload
- pass complex json as shortcode parameter
- remove SLASH on single_post but KEEP on categories and parent pages
- Image Caption Shortcode Broken upon update
- How to cache a custom API call?
- Dequeue styles with query doesn’t work
- Using a WP shortcode in Homepage
- How can Use custom input field in functions.php page?