post-meta

set post per page using get_post_meta

左心房为你撑大大i 提交于 2019-12-25 04:10:45
问题 I have code to show get_meta_post per page this my code if ( have_posts() ) : while ( have_posts() ) : the_post(); $metas = get_post_meta(get_the_ID(),'value_gallery',false); //var_dump($metas); ==> will output array(1) { [0]=> string(29) "1434,1402,1434,1435,1398,1434" } foreach ($metas as $key ) { $key_val = explode(",", $key); $page = get_query_var('page'); $page = $page > 1 ? $page - 1 : 0 ; if (isset($key_val[$page])) { echo "<div class='col-lg-4'>". wp_get_attachment_image($key_val[

Wordpress On Edit Post Page Save, Update Post Meta

蓝咒 提交于 2019-12-11 17:06:33
问题 I am trying to create/update post meta when you create/update a post that is specifically a post type of "offer". However, it does not update the post meta. This code is added in my functions.php file. add_filter( 'pre_post_update', 'update_voucher_deadline', 10, 2 ); function update_voucher_deadline( $post_id, $data ) { $evergreen = get_field('offer_evergreen', $post_id); if ($evergreen == "evergreen-yes") { $year = date('Y'); $month = date('m'); $currentDate = "". $year . "-" . $month . "-"

Custom Post Type rating not working

这一生的挚爱 提交于 2019-12-11 14:45:33
问题 Using the following code I managaed to add Rating to my custom post_type and I intend to show star signs according to number of rating: function display_game_meta_box( $game ) { // Retrieve current name of the Author and Game Rating based on review ID $game_Author = esc_html( get_post_meta( $game->ID, 'game_Author', true ) ); $game_rating = intval( get_post_meta( $game->ID, 'game_rating', true ) ); ?> <table> <tr> <td style="width: 100%">Game Author</td> <td><input type="text" size="80" name=

Update product variations prices in Woocommerce with WPDB query

♀尐吖头ヾ 提交于 2019-12-01 12:55:51
I am using WordPress 4.7.4 and WooCommerce 3.0.5. I updated _sale_price , _price , _regular_price using meta_id with code below: $meta_tbl = $wpdb->prefix.'postmeta'; foreach ($_POST['loop'] as $loop_k => $loop_v) { $wpdb->update( $meta_tbl, array( 'meta_value' => $loop_v['price'] ), array( 'meta_id' => $loop_v['price_meta_id'] ), array( '%d' ) ); $wpdb->update( $meta_tbl, array( 'meta_value' => $loop_v['regular_price'] ), array( 'meta_id' => $loop_v['regular_price_meta_id'] ), array( '%d' ) ); $wpdb->update( $meta_tbl, array( 'meta_value' => $loop_v['sale_price'] ), array( 'meta_id' => $loop

Update product variations prices in Woocommerce with WPDB query

假装没事ソ 提交于 2019-12-01 12:16:25
问题 I am using WordPress 4.7.4 and WooCommerce 3.0.5. I updated _sale_price , _price , _regular_price using meta_id with code below: $meta_tbl = $wpdb->prefix.'postmeta'; foreach ($_POST['loop'] as $loop_k => $loop_v) { $wpdb->update( $meta_tbl, array( 'meta_value' => $loop_v['price'] ), array( 'meta_id' => $loop_v['price_meta_id'] ), array( '%d' ) ); $wpdb->update( $meta_tbl, array( 'meta_value' => $loop_v['regular_price'] ), array( 'meta_id' => $loop_v['regular_price_meta_id'] ), array( '%d' )