Using wp_handle_upload() to Direct Specific Path by Using $overrides

You need to specify a list of allowed mime types. You could make it easy by just getting the allowed mime types like: $file = $_FILES[‘the-file’]; $upload_file = wp_handle_upload($file, array( ‘test_form’ => false, ‘mimes’ => get_allowed_mime_types() )); If you look at the codex for Default allowed mime types, you could manually specify which ever mime … Read more

How pass a 0 in $atts?

This happens, because WP checks the value with empty(): if ( ! empty( $value ) ) … and empty() is TRUE for values like 0 or “0”. You have two options now: Filter walker_nav_menu_start_el and replace <a with <a tabindex=0. Pass $atts[‘tabindex’] = “0 “; in your original function. Note the extra space. It circumvents … Read more

Return array keys and values

This is not really a WordPress question but more PHP. To solve this problem, you need to use $value as your key as well plus _id You can do something like this $options[$value . ‘_id’] = ot_get_option($value); EDIT If you need $key to be the value of id, you can also try something like this … Read more

Call global variable array() in woocommerce child/template

It is all fine. You just need to declare variable global first then you can set the value of this and access globally. function my_free_shipping( $is_available ) { global $woocommerce, $product_notfree_ship; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( ‘1’, ‘2’, ‘3’, ‘4’, ‘5’ ); Then again declare it globally when using … Read more

Recent posts with featured image or fallback image with permalink

Here’s the relevant part of your code that should work: // This will make a URL like http://yoursite.com/path/to/fallback.png $fallback_image = site_url( ‘/path/to/fallback.png’ ); $fallback_image = “<img src=”https://wordpress.stackexchange.com/questions/224740/{$fallback_image}” />”; foreach( $recent_posts as $recent ){ echo ‘<div class=”sidebar-entries”>’; $featured_image = get_the_post_thumbnail( $recent[‘ID’], ‘sidebar-thumb’, array( ‘class’ => ‘sidebar-image’ ) ); if ( ! strlen( $featured_image ) ) { … Read more

Changing a specific value inside a complex repeater/flexible content field (ACF)

Answering my own question again. 😛 I finally found this Gist that lets me get and set array variables via dot notation: https://gist.github.com/elfet/4713488 So I included the DotNotation class and now my code looks like this (skipping all sorts of error checking here) : $fieldmap_string = ‘key1.key2.key3.etc’; $current_page_content = get_field(‘page_content’, $source_post_id); $parsed_current_content = new DotNotation($current_page_content); … Read more