New answers tagged

0

You can do it either by editing the database table wp_postmeta: searching for the post_id = 63 and meta_key = 'Header Info1', and then editing the meta_value value. The other, probably easier option, is to call a function update_post_meta(), like this: <?php query_posts("page_id=63"); while ( have_posts() ) : the_post(); update_post_meta( ...


1

The $havemeta variable isn't defined inside your shopping_location_text() function, so it isn't available for use there. For a quick fix (or for testing/toying) you can move your code inside the function, like this: add_action( 'woocommerce_before_main_content', 'shopping_location_text', 10 ); function shopping_location_text() { global $current_user; ...


0

You can do this several different ways. Need to know how you are passing the 1 custom field in your current shortcode. It seems like you might be doing it like this: [your_short_code price="how_are_you_setting_this"] if this is the case then you can just add more attributes like this: [your_short_code price="how_are_you_setting_this" next_field="...


0

Try Fire it on init instead of inside register_post_type like this: add_action('init','345376_register_metaof_team'); function 345376_register_metaof_team(){ $object_type = 'team'; $args = array( 'type' => 'string', 'description' => 'A meta key associated with post views.', 'single' => true, 'show_in_rest' => true,...


0

You could output them as inline CSS custom properties instead of left/top, and then use those to set the position in either CSS or Javascript. PHP: <a class="project" href="<?php the_permalink(); ?>" style="—-x-position: <?php the_field('x'); ?>; —-y-position: <?php the_field('y'); ?>;'"> <p><?php the_field("title"); ?...


0

You can use wp_localize_script() function to pass value into js. For example add_action( 'wp_enqueue_scripts', 'my_custom_scripts' ); public function my_custom_scripts() { wp_enqueue_script( 'custom-script', get_stylesheet_directory_uri() . '/js/custom_script.js', ['jquery'] ); wp_localize_script( 'custom-script', 'myScript', [ 'var_a' =>...


0

Literally just figured this out on my own by reviewing str_replace documentation again. <?php $price_meta = get_post_meta($post->ID, "_price", true); $price_meta_stripped = str_replace(',', '', $price_meta); echo $price_meta_stripped; ?>


0

Thanks! I was close to the solution, tried both, but not in combination. Thus $enddatevar = get_post_meta( $post->ID, $key = 'enddate', $single = false); update_post_meta( $post->ID, 'promote', $enddatevar ); worked.


1

$enddatevar = get_post_meta( $post_id, $key = 'enddate', $single = false); $post_id is not defined, either declare it beforehand, or use $post->ID. update_post_meta( $post->ID, 'promote', '$enddatevar' ); '$enddatevar' shouldnt be inside quotes.


0

add_action( 'add_meta_boxes', 'add_tmbu_address_meta_box' ); function add_tmbu_address_meta_box() { $screens = array( 'post', 'page' ); add_meta_box( 'your_fields_meta_box','Tmbu Address','show_tmbu_address_meta_box',$screens,'advanced','high' ); }


0

You have to create custom query, to get data from {$wpdb->prefix}postmeta depending on the meta_key and store the meta_values inside an array, then sum them. So we can build a function like this: /** * Query meta values by meta key. * * @return int Returns sum of meta values */ function get_meta_value_by_meta_key(){ global $wpdb; $metaValues =...


0

Actually you are wrapping every thing with a div with class team-model, where this class is the responsible of showing the model, so if you click within the div at any where, e.g. title, link, you are actually clicking on the div itself, so team-model will fire its bind event. so just the items you want it to show the model give it only the class team-model


0

There are tutorials online. For example - https://www.skyverge.com/blog/sort-woocommerce-products-custom-fields/ Here is the main code to put into functions - https://gist.github.com/bekarice/0df2b2d54d6ac8076f84 <?php /** * Adds WooCommerce catalog sorting options using postmeta, such as custom fields * Tutorial: http://www.skyverge.com/blog/sort-...


0

The correct symbol for abbreviating feet and inches is actually "Prime" and "Double Prime" respectively. You can read about it more here. I'm not sure if this site will change the character but ′ is Prime and ″ is Double Prime. If you can't copy/paste them from there, you could copy/paste them from the link above. The link above also lists the ...


0

You can use wp_schedule_single_event to run once. Other way maybe: * Run code only once */ function change_postkey_only_once() { if (get_option('change_postkey_only_once_01') != 'completed') { global $wpdb; $query = "UPDATE " . $wpdb->prefix . "postmeta SET meta_key = 'new_key_name' WHERE meta_key = '...


0

Add this to the frontend and you should be able to adjust it to display whatever field you've added. $user_info = get_userdata(get_current_user_id()); echo 'Username: ' . $user_info->user_login . "<br>"; echo 'User roles: ' . implode(', ', $user_info->roles) . "<br>"; echo 'User ID: ' . $user_info->ID . "<br>"; echo 'User Agent ...


0

$args = [ 's' => $keyword, 'post_type' => ['page'], 'paged' => $paged, 'posts_per_page' => PAGE_LIMIT, 'tax_query' => [ [ 'taxonomy' => TAX_RESOURCE_PAGE, 'field' => 'slug', 'terms' ...


0

Assuming the $value actually returns a post's ID. Replace the code wp_add_post_tags( $post_id, $value ); With wp_add_post_tags( $post_id, sanitize_title( get_the_title( $value[0] ) ) );


Top 50 recent answers are included