Retrieve post thumbnail as array

The solution is to use wp_get_attachment_image_src. As per the Codex: $attachment_id = 8; $size=”full”; // returns an array $image_attributes = wp_get_attachment_image_src( $attachment_id, $size ); Although the return is said to be: [0] => url [1] => width [2] => height There is a fourth element that indicates if it is the full image (false) or … Read more

Resort get_categories

There is already a function in WordPress doing that: wp_terms_checklist(). It is used in the metabox for hierarchical taxonomies in the post editor. Maybe you can reuse that? The following is untested, see it just as a guide please, not as a complete solution: // File where “wp_terms_checklist()” is declared require_once ABSPATH . ‘wp-admin/includes/template.php’; // … Read more

How to save data of an input field to an array

Don’t use update_usermeta, it is deprecated, update_user_meta is the one to use. You get the previously saved value out with get_user_meta. <input type=”text” name=”group[]” id=’group[]’ class=”regular-text” value=”<?php echo esc_attr( get_user_meta( $user->ID, ‘group’, true ) ); ?>” />

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)