How to get default variation ID (woocommerce)

Try this code add_filter(‘woocommerce_variable_price_html’, ‘custom_variation_price’, 10, 2); function custom_variation_price( $price, $product ) { $available_variations = $product->get_available_variations(); $selectedPrice=””; $dump = ”; foreach ( $available_variations as $variation ) { // $dump = $dump . ‘<pre>’ . var_export($variation[‘attributes’], true) . ‘</pre>’; $isDefVariation=false; foreach($product->get_default_attributes() as $key=>$val){ // $dump = $dump . ‘<pre>’ . var_export($key, true) . ‘</pre>’; // $dump … Read more

Saving custom input from settings sidebar of pages in WordPress

You have forgot to add name of the input box so kindly modify your code for meta box creation as below function j_meta_box_cb( $post ) { $value = get_post_meta( $post->ID, ‘j-icon’, true ); ?> <input id=”j-meta-box” type=”text” name=”j-icon”value=”<?php echo esc_attr( $value ) ?>”></input> <?php } Let me know still if you hv any queries.

ACF – How to get custom taxonomy term image field

I found a solution for this: <?php $current_term_id = get_queried_object_id(); $taxonomyName = “car-brand”; $parent_tax_ID = $current_term_id; $parent_tax = get_term($parent_tax_ID); $terms = get_terms( $taxonomyName, array( ‘parent’ => $parent_tax_ID, ‘orderby’ => ‘slug’, ‘hide_empty’ => false ) ); foreach ( $terms as $term ) { $image2 = get_field(‘am-brand-img’, $term); echo ‘ <div class=”am-ts-item”> <a href=”‘ . get_term_link( $term … Read more

Add another user role based on a defined input field in WordPress (Woocommerce)

Add the following code snippet to your WordPress theme’s functions.php file. Define the new user role and capabilities (you can customize this based on your needs) function add_custom_roles() { add_role( ‘corporate_customer’, ‘Corporate Customer’, array( ‘read’ => true, ‘edit_posts’ => true, ‘delete_posts’ => false, )); } add_action( ‘init’, ‘add_custom_roles’ ); A function to update the user … Read more

Display data with a yes or no condition ACF

if ( get_field( “models-ad_fly” ) ): echo ‘<div class=”icon_plane”><i class=”icon-social_fly”></i></div>’; endif; or if you want to assign the output to a variable if ( get_field( “models-ad_fly” ) ): $output .= ‘<div class=”icon_plane”><i class=”icon-social_fly”></i></div>’; endif;

Error while add Category or Tag in WordPress

Rename the “plugins” folder in “wp-content” and create a new empty “plugins” folder. Test if the error persists. Temporarily revert any custom code or modifications in your theme. Add a higher memory limit to “wp-config.php.” Use the “WP-Optimize” plugin to optimize and repair the database. Check for error messages by enabling WordPress debugging in “wp-config.php.” … Read more

WP Query order posts not working

To sort by title in ascending order (alphabetical order), you can use orderby => title and order => ASC: $args = array( ‘post_type’ => ‘marketing_en’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘custom_post_type’, ‘field’ => ‘slug’, ‘terms’ => array(ICL_LANGUAGE_CODE == ‘ar’ ? ‘tool-ar’ : ‘tool’), ), ), ); $loop = … Read more