Skip to content

Instantly share code, notes, and snippets.

@mAAdhaTTah
Created February 16, 2015 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mAAdhaTTah/78a94a881429f0c9f4a5 to your computer and use it in GitHub Desktop.
Save mAAdhaTTah/78a94a881429f0c9f4a5 to your computer and use it in GitHub Desktop.
Using Redirect Args to Display Errors
if ( ! empty( $errors ) ) {
    add_filter('redirect_post_location', function( $location ) use ( $errors ) {
        return add_query_arg( 'gistpen-errors', implode( ",", $errors ), $location );
    });
}
if ( array_key_exists( 'gistpen-errors', $_GET) ) { ?>
    <div class="error">
        <p><?php
            echo 'The post saved with error codes: ' . $_GET['gistpen-errors'];
        ?></p>
    </div><?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment