admin管理员组文章数量:1426072
Please me!!!! Itried thow weeks and I search but without any result I can't save meta box that has both checkbox i need your help as soon as possible this is my code callback my metabox :
$terms = get_terms( 'type_livre', $terms = get_terms( 'type_livre',
array(
array(
`
<div>
<?php
$terms = get_terms( 'type_livre',
array(
'orderby' => 'id',
'hide_empty' => 1
)
);
foreach( $terms as $term ) {
$args = array(
'post_type' => 'livre',
'type_livre' => $term->slug taxonomy
);
$query = new WP_Query( $args );
echo'<h2 class="h2 faq-cat">' . $term->name . '</h2>';
while ( $query->have_posts() ) : $query->the_post(); ?>
<input type="checkbox" name="check_list" id="<?php the_ID(); ?>" value="<?php the_title() ; ?>" >
<label for="<?php the_ID(); ?>">
<?php the_title() ; ?>
</label>
<label for="Qte_livre" style="margin-left: 352px;buttom">
<?php echo 'Qte'; ?>
</label>
<input type="number" id="Qte_livre" name="Qte_livre" style="margin-left: 452px;"/>
<?php endwhile; wp_reset_postdata();
echo '<hr/>';
wp_reset_postdata();
}
`
Please me!!!! Itried thow weeks and I search but without any result I can't save meta box that has both checkbox i need your help as soon as possible this is my code callback my metabox :
$terms = get_terms( 'type_livre', $terms = get_terms( 'type_livre',
array(
array(
`
<div>
<?php
$terms = get_terms( 'type_livre',
array(
'orderby' => 'id',
'hide_empty' => 1
)
);
foreach( $terms as $term ) {
$args = array(
'post_type' => 'livre',
'type_livre' => $term->slug taxonomy
);
$query = new WP_Query( $args );
echo'<h2 class="h2 faq-cat">' . $term->name . '</h2>';
while ( $query->have_posts() ) : $query->the_post(); ?>
<input type="checkbox" name="check_list" id="<?php the_ID(); ?>" value="<?php the_title() ; ?>" >
<label for="<?php the_ID(); ?>">
<?php the_title() ; ?>
</label>
<label for="Qte_livre" style="margin-left: 352px;buttom">
<?php echo 'Qte'; ?>
</label>
<input type="number" id="Qte_livre" name="Qte_livre" style="margin-left: 452px;"/>
<?php endwhile; wp_reset_postdata();
echo '<hr/>';
wp_reset_postdata();
}
`
Share
Improve this question
edited May 21, 2019 at 7:33
Mayeenul Islam
12.9k21 gold badges85 silver badges169 bronze badges
asked May 21, 2019 at 7:19
SihamSiham
1
1
|
1 Answer
Reset to default 0i don't know how can i save this metabox please helpe me. This Is my code :
<?php
function book_function_meta_box(){
add_meta_box('book_meta_box', 'more Infos', 'book_meta_box_callback', 'book', 'normal');
}
add_action('add_meta_box', 'book_add_meta_box');
function book_meta_box_callback()
{
wp_nonce_field('book_save_meta_box_data', 'book_nonce_name');
$terms = get_terms(
'category',
array(
'orderby' => 'id',
'hide_empty' => 1 // hide categories with no posts
)
);
foreach ($terms as $term) {
$args = array(
'post_type' => 'book',
'category' => $term->slug
);
$query = new WP_Query($args);
echo '<h2 class="h2 faq-cat">' . $term->name . '</h2>';
while ($query->have_posts()) : $query->the_post();
$livre_slug = sanitize_title_with_dashes(get_the_title(get_the_ID()));
$qte_slug = $livre_slug . 'qte';
?>
<div>
<label for="<?php the_ID(); ?>">
<?php echo '<h1>' . the_title() . '</h1>'; ?>
</label>
<input type="checkbox" name="<?php echo $livre_slug; ?>" id="<?php the_ID(); ?>" value="<?php the_title(); ?>" <?php if (isset($_POST[$livre_slug])) echo 'checked="checked"'; ?> />
<label for="<?php echo $qte_slug; ?>" style="margin-left: 352px;buttom">
<?php echo 'Qte'; ?>
</label>
<input type="number" id="<?php the_ID(); ?>" name="<?php echo $qte_slug; ?>" style="margin-left: 452px;" value="<?php echo esc_attr(get_post_meta(get_the_ID(), $qte_slug, true)); ?>" />
</div>
<?php
wp_reset_postdata();
endwhile;
// use reset postdata to restore the original query
wp_reset_postdata();
}
}
本文标签: metabox dosn39t save with checkbox of posttype values order by taxonomy
版权声明:本文标题:metabox dosn't save with checkbox of post_type values order by taxonomy 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745468115a2659623.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_reset_postdata()
– mlimon Commented May 21, 2019 at 7:56