Best way to sort posts with different types by distance

OK, I added distance as custom field to allow me order them using wp_query orderby method! function add_distance_as_customfield($posts){ $longDest = $_GET[‘lng’]; $latDest = $_GET[‘ltd’]; foreach ($posts as $post) { $placeLocation= get_field(‘location’,$post->ID); $longPlace =$placeLocation[‘lng’]; $latPlace = $placeLocation[‘lat’]; $distance=getDistance($latDest,$longDest,$latPlace,$longPlace); if ( ! add_post_meta($post->ID, “distance”, $distance,true ) ) { update_post_meta( $post->ID, “distance”, $distance ); } } }

after checked the checkbox in backend, dont show social link on frontend

It cannot be in post metabox, because it is site setting, not specific page. You can create submenu position for settings in your admin panel by add_submenu_page function, for example: add_action(‘admin_menu’, ‘add_my_settings_submenu_page’); function add_my_settings_submenu_page() { add_submenu_page(‘options-general.php’, ‘Page title’, ‘Menu title’, ‘manage_options’, ‘my_settings’, ‘my_settings_submenu_callback’); } Then you need to create callback for last argument where will … Read more

adding a custom time class to in theme twenty sixteen

Twentysixteen’s header and functions.php appear to support the body_class filter. add_filter(‘body_class’, ‘my_body_classes’); function my_body_classes($classes) { global $wp_query; $time = time() + ( get_option( ‘gmt_offset’ ) * 3600 ); $classes[] = ‘w’ . gmdate( ‘W’, $time ); if ( is_page() && $wp_query->post->post_parent ){ $classes[] = ‘parent-‘ . $wp_query->post->post_parent; } return $classes; }

Changing ‘Add to cart’ button text and relink for some specific products [closed]

Per Ashish’s answer that’s been posted, below is the update code for clarification with the correct answer by switching add_to_cart_url() to get_permalink(): global $product, $post; $hasCustomization = get_post_meta( $post -> ID, ‘_wcm_custom_design_checkbox’, true ); if ( $hasCustomization == ‘on’ ) { echo apply_filters( ‘woocommerce_loop_add_to_cart_link’, sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/237352/%s” rel=”nofollow” data-product_id=”https://wordpress.stackexchange.com/questions/237352/%s” data-product_sku=”https://wordpress.stackexchange.com/questions/237352/%s” class=”add_to_cart %s product_type_%s”>%s</a>’, esc_url( $product … Read more