here i'm trying on submitting to delete the post in process.. i've tried without the hidden input aswell as doing the if isset on the redirecting page when form's submit. all 3 ways failed.

       && isset($_POST['idValue']))

        $post_type = $_POST['postType'];
        $id_post = $_POST['idValue'];               

        $postInfo = array(
            'post_type' => $post_type,
            'ID' => $id_post

        wp_delete_post($postInfo, true);


    if(isset($_GET['action']) && $_GET['action'] == "Supprimer")


            <div id="overlay">
                <div id="SupprimerAnnonce">

                    <form method="post" action="<?php echo add_query_arg( 'action', 'Deleted', $_SERVER['HTTP_REFERER']); ?>">
                        <p>&Ecirc;tes-vous s&ucirc;r de vouloir supprimer</p>
                        <p><b><?php the_field('titre') ?></b></p>
                        <input type="submit" name="delete" value="Continuer"/>

                            $post_type = get_post_type( get_the_ID() );
                            $id_post = get_the_ID();


                            <input type="hidden" name="idValue" value="<?php echo $id_post; ?>" readonly />
                            <input type="hidden" name="postType" value="<?php echo $post_type; ?>" readonly />

                <a href="javascript:void(0)" onclick="document.getElementById('overlay').style.display='none';document.getElementById('fade').style.display='none'" title="Fermer">Fermer</a>
            <div id="fade"></div>



Any tips ?


  • Debug your outcomes. Your conditions might not be getting met. Put some else statements on there and output that stuff to a log file or something.
    – GhostToast
    Oct 29, 2013 at 15:45
  • Here is what i tried. instead of having multiple condition on one page, if the user click continue on deleting the post i redirect to action.php which will hold the condition looking for the $post_type and the $id_post. So far i can echo both of them to test if the $_POST did his job but i'm still unable to delete in the custom post type ex : Bateaux
    – pouki
    Oct 29, 2013 at 17:31
  • Are you actually doing this inside wordpress? does action.php include get_header(); etc?
    – GhostToast
    Oct 29, 2013 at 17:42
  • i solved the solution using a foreach if is array :) thks for your time.
    – pouki
    Oct 29, 2013 at 17:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.