Charles_Mad

input

Jul 27th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. $myposts = get_posts($args);
  2.  
  3. foreach( $myposts as $post ) : setup_postdata($post);
  4.  
  5. $checked = is_array($cats) && in_array(get_the_ID(), $cats) ? 'checked="checked"' : '';
  6.  
  7. ?>
  8.  
  9. <label><input <?php echo $checked; ?> type="checkbox" name="myposts[]" value="<?php the_ID(); ?>" id="myposts[]" /><?php the_title(); ?></label>
  10. <br>
  11. Custo <input type="text" name="etapa_custo[<?php echo $post_id?>]" value="" />
  12.  
  13. <br>
  14.  
  15. <?php
  16.  
  17. endforeach;
  18.  
  19. }
  20.  
  21.  
  22. }
  23.  
  24. add_action( 'save_post', 'salvar_post_etapas' );
  25. function salvar_post_etapas( $post_id ){
  26. if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
  27. if( isset( $_POST['myposts'])){
  28. update_post_meta( $post_id, 'myposts', $_POST['myposts']);
  29.  
  30. }else{
  31. update_post_meta( $post_id, 'myposts', array());
  32. }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment