my code is working properly but little problem here. I am using bellow code and my check box meta field properly working but not stay tick mark in checkbox after publish post. Maybe, some mistake in my code that not find out by me. Please any one help me.
<?php
function pricing_table_shortcode($atts) {
extract(shortcode_atts( array(
'category' => '',
),
$atts, 'pricing') );
$q = new WP_Query( array(
'posts_per_page'=> '4',
'post_type'=> 'pricing_table_items',
'std' => 'column_width',
'meta_key'=> 'post_order',
'orderby' => 'meta_value',
'order' => 'ASC')
);
$list = '<div class="table_tracture">';
while($q->have_posts()) : $q->the_post();
$idd = get_the_ID();
$recommended = get_post_meta($idd, 'recommended', true);
$list .= '';
endwhile;
$list.='</div>';
wp_reset_query();
return $list;
}
add_shortcode('pricing-table','pricing_table_shortcode');
function display_pricing_table_items_meta_box( $pricing_table_items ) {
$recommended = esc_html( get_post_meta( $pricing_table_items->ID, 'recommended', true ) );
?>
<table>
<tr valign="top" id="wds_table_id">
<th scope="row"><label for="back_color">Highlighted Item</label></th>
<td>
<input type="checkbox" name="recommended_name" value="recommended"/><p class="description"></p>
<p class="description"></p>
</td>
</tr>
</table>
<?php
}
add_action( 'save_post', 'add_pricing_table_items_fields', 10, 2 );
function add_pricing_table_items_fields( $pricing_table_items_id, $pricing_table_items ) {
// Check post type for movie reviews
if ( $pricing_table_items->post_type == 'pricing_table_items' ) {
// Store data in post meta table if present in post data
if ( isset( $_POST['recommended_name'] ) && $_POST['recommended_name'] != '' ) {
update_post_meta( $pricing_table_items_id, 'recommended', $_POST['recommended_name'] );
}
}
}
?>
Aucun commentaire:
Enregistrer un commentaire