0

だから私はメタボックスを持っています...次のようなチェックボックスの配列があります:

name="my_field[]" value="1"
name="my_field[]" value="2"
name="my_field[]" value="3"
name="my_field[]" value="4"
name="my_field[]" value="5"

そして、投稿を確認すると、選択したものだけでなく、すべてのチェックボックスが送信されます。それが必要です。誰かがこれを奨励しましたか?

//LE

wp-content/uploads/2012/10/Abstract_Brush-51610.jpeg

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/10/Abstract_Wallpapers_35.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/10/Abstract_Wallpapers_35.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/10/Abstract-Desktop-Wallpapers-Mac-Apple-Pictures.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/10/Abstract-Desktop-Wallpapers-Mac-Apple-Pictures.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/7.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/7.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/6.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/6.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/5.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/5.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/a6057e6bac44bc179398ed2e2d5d3a2c.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/a6057e6bac44bc179398ed2e2d5d3a2c.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/2535f67307340667d7e7228115fa517d.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/2535f67307340667d7e7228115fa517d.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/1680x1050.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/1680x1050.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/09/5cf4ba58c8c20201cfaac290fd247d75.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/09/5cf4ba58c8c20201cfaac290fd247d75.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/08/Gibraltar.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/08/Gibraltar.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/08/background_01.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/08/background_01.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/08/bg1.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/08/bg1.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/08/bg_21.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/08/bg_21.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/08/bg.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/08/bg.jpg'  />                            </p>

                        <p>

                                                        </p>


                        <p>
                            <label>wp-content/uploads/2012/08/bg_2.jpg</label>
                            <input type='checkbox' name='choose_from_library[]' value='wp-content/uploads/2012/08/bg_2.jpg'  />                            </p>

//LE $_POST var_dump

    array(52) { ["_wpnonce"]=> string(10) "924c761932" ["_wp_http_referer"]=> string(53) "/scai/wp-admin/post-new.php?post_type=backgroundslide" ["user_ID"]=> string(1) "1" ["action"]=> string(8) "editpost" ["originalaction"]=> string(8) "editpost" ["post_author"]=> int(1) ["post_type"]=> string(15) "backgroundslide" ["original_post_status"]=> string(10) "auto-draft" ["referredby"]=> string(84) "wp-admin/post-new.php?post_type=backgroundslide" ["_wp_original_http_referer"]=> string(84) "wp-admin/post-new.php?post_type=backgroundslide" ["auto_draft"]=> string(1) "0" ["post_ID"]=> string(3) "167" ["autosavenonce"]=> string(10) "98077d6315" ["meta-box-order-nonce"]=> string(10) "2d068e8263" ["closedpostboxesnonce"]=> string(10) "552f6efbaa" ["post_title"]=> string(16) "dasdadadadadadad" ["samplepermalinknonce"]=> string(10) "8f1ffd40fb" ["content"]=> string(0) "" ["wp-preview"]=> string(0) "" ["hidden_post_status"]=> string(5) "draft" ["post_status"]=> string(7) "publish" ["hidden_post_password"]=> string(0) "" ["hidden_post_visibility"]=> string(6) "public" ["visibility"]=> string(6) "public" ["post_password"]=> string(0) "" ["mm"]=> string(2) "10" ["jj"]=> string(2) "06" ["aa"]=> string(4) "2012" ["hh"]=> string(2) "08" ["mn"]=> string(2) "40" ["ss"]=> string(2) "43" ["hidden_mm"]=> string(2) "10" ["cur_mm"]=> string(2) "10" ["hidden_jj"]=> string(2) "06" ["cur_jj"]=> string(2) "06" ["hidden_aa"]=> string(4) "2012" ["cur_aa"]=> string(4) "2012" ["hidden_hh"]=> string(2) "08" ["cur_hh"]=> string(2) "08" ["hidden_mn"]=> string(2) "40" ["cur_mn"]=> string(2) "40" ["original_publish"]=> string(7) "Publish" ["publish"]=> string(7) "Publish" ["post_name"]=> string(0) "" ["jw_nonce"]=> string(10) "d9cc45b5e2" ["set_for_page"]=> string(7) "Contact" ["choose_from_library"]=> array(3) { [0]=> string(89) "wp-content/uploads/2012/10/Abstract_Brush-51610.jpeg" [1]=> string(90) "wp-content/uploads/2012/10/Abstract_Wallpapers_35.jpg" [2]=> string(114) "wp-content/uploads/2012/10/Abstract-Desktop-Wallpapers-Mac-Apple-Pictures.jpg" } ["post_mime_type"]=> string(0) "" ["ID"]=> int(167) ["post_content"]=> string(0) "" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" }
    array(68) { ["_wpnonce"]=> string(10) "924c761932" ["_wp_http_referer"]=> string(53) "/scai/wp-admin/post-new.php?post_type=backgroundslide" ["user_ID"]=> string(1) "1" ["action"]=> string(8) "editpost" ["originalaction"]=> string(8) "editpost" ["post_author"]=> int(1) ["post_type"]=> string(15) "backgroundslide" ["original_post_status"]=> string(10) "auto-draft" ["referredby"]=> string(84) "wp-admin/post-new.php?post_type=backgroundslide" ["_wp_original_http_referer"]=> string(84) "wp-admin/post-new.php?post_type=backgroundslide" ["auto_draft"]=> string(1) "0" ["post_ID"]=> string(3) "167" ["autosavenonce"]=> string(10) "98077d6315" ["meta-box-order-nonce"]=> string(10) "2d068e8263" ["closedpostboxesnonce"]=> string(10) "552f6efbaa" ["post_title"]=> string(16) "dasdadadadadadad" ["samplepermalinknonce"]=> string(10) "8f1ffd40fb" ["content"]=> string(0) "" ["wp-preview"]=> string(0) "" ["hidden_post_status"]=> string(5) "draft" ["post_status"]=> string(7) "publish" ["hidden_post_password"]=> string(0) "" ["hidden_post_visibility"]=> string(6) "public" ["visibility"]=> string(6) "public" ["post_password"]=> string(0) "" ["mm"]=> string(2) "10" ["jj"]=> string(2) "06" ["aa"]=> string(4) "2012" ["hh"]=> string(2) "08" ["mn"]=> string(2) "40" ["ss"]=> string(2) "43" ["hidden_mm"]=> string(2) "10" ["cur_mm"]=> string(2) "10" ["hidden_jj"]=> string(2) "06" ["cur_jj"]=> string(2) "06" ["hidden_aa"]=> string(4) "2012" ["cur_aa"]=> string(4) "2012" ["hidden_hh"]=> string(2) "08" ["cur_hh"]=> string(2) "08" ["hidden_mn"]=> string(2) "40" ["cur_mn"]=> string(2) "40" ["original_publish"]=> string(7) "Publish" ["publish"]=> string(7) "Publish" ["post_name"]=> string(0) "" ["jw_nonce"]=> string(10) "d9cc45b5e2" ["set_for_page"]=> string(7) "Contact" ["choose_from_library"]=> array(3) { [0]=> string(89) "wp-content/uploads/2012/10/Abstract_Brush-51610.jpeg" [1]=> string(90) "wp-content/uploads/2012/10/Abstract_Wallpapers_35.jpg" [2]=> string(114) "wp-content/uploads/2012/10/Abstract-Desktop-Wallpapers-Mac-Apple-Pictures.jpg" } ["post_mime_type"]=> string(0) "" ["ID"]=> int(167) ["post_content"]=> string(0) "" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["choose_from_library_wp-content/uploads/2012/10/abstract_brush-51610.jpeg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/10/abstract_wallpapers_35.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/10/abstract-desktop-wallpapers-mac-apple-pictures.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/7.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/6.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/5.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/a6057e6bac44bc179398ed2e2d5d3a2c.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/2535f67307340667d7e7228115fa517d.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/1680x1050.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/09/5cf4ba58c8c20201cfaac290fd247d75.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/08/gibraltar.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/08/background_01.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/08/bg1.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/08/bg_21.jpg"]=> string(0) "" ["choose_from_library_wp-content/uploads/2012/08/bg.jpg"]=> string(0) "" 

["choose_from_library_wp-content/uploads/2012/08/bg_2.jpg"]=> string(0) "" }
4

1 に答える 1

0

それらはすべて choose_from_library[] という名前なので、チェックしたものだけを送信するように指定しない限り、すべてを受信することになります。jqueryで次のようなものを使用して、投稿する前にチェックされているボックスをフィルタリングします。

$('input[name="choose_from_library"]').is(':checked');

または、選択したバックエンド言語でサーバー側でフィルタリングします。

于 2012-10-06T08:47:29.343 に答える