rdellconsulting Posted March 8, 2014 Share Posted March 8, 2014 php newbie, have spent days trying to fix this so I hope somebody can put me out of my misery! I'm using WP + Advanced Custom Fields. I have a Custom Post Type (Minutes) which has either Draft or Approved posts. I'm trying to iterate the data to find Draft items and offer the option of changing to Approved. My code has extracted 3 Draft items. It's showing the 3 radio button groups. Problem: I cannot find how to get 3 values of 'status'. I either get a single value of '0', or '1' if any of the 3 radios is entered checked. The debug print_r & echo is showing: Array ( [0] => Array ( [postid] => 2557 [count] => 0 ) [1] => Array ( [postid] => 2545 [count] => 1 ) [2] => Array ( [postid] => 2541 [count] => 2 ) ) Key: 0, Value: 1 Here's my code: <?php /** * Template Name: Approve Minutes * * Print posts of a Custom Post Type. */ get_header(); ?> <div id="container"> <div id="content"> <?php $type = 'minutes'; $args = array ( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => -1, 'ignore_sticky_posts'=> 1 ); $temp = $wp_query; // assign ordinal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); $draftcount = 0; if ( $wp_query->have_posts() ) : ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); if( !get_field('rdc_appstatus') ) // Test if false (=Draft) {$metastatus = "Draft";} else {continue;} $post_id = get_the_ID(); $posttitle = get_the_title(); $metafile = get_field('rdc_filename'); ?> <div class="span2 approve"> <form action="#" method="post"> <table> <tr><td><label><input id="toggle" type="radio" name="status[]" value="0" checked/>Draft</label></td></tr> <tr><td><label><input id="toggle" type="radio" name="status[]" value="1" />Approved</label></td></tr> <tr><td colspan="3" align="center"><input type="submit" name="submit" value="Confirm"/></td></tr> </table> </form> </div> <?php $drafts[$draftcount] = array ( 'postid' => $post_id, 'count' => $draftcount ); $draftcount++; endwhile; echo '<h3> '.$draftcount.' Draft Items Found</h3>'; ?> </ul> </div> <?php if (isset($_POST['status'])) { print_r ( $drafts); while (list($key,$value) = each($_POST['status'])) { echo "Key: $key, Value: $value <br />"; } } ?> <?php else : echo '<h3>No Draft Items Found</h3>'; endif; $wp_query = $temp; ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.