Add file to media library programmatically

<?php $file = ‘/path/to/file.png’; $filename = basename($file); $upload_file = wp_upload_bits($filename, null, file_get_contents($file)); if (!$upload_file[‘error’]) { $wp_filetype = wp_check_filetype($filename, null );…

7 سال پیش

Remove Woocommerce User Fields

put it in function.php on template folder /* Remove Woocommerce User Fields */ add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ ); add_filter( ‘woocommerce_billing_fields’…

8 سال پیش

woocommerce disable checkout fields

add_filter( ‘woocommerce_billing_fields’, ‘wc_optional_billing_fields’, 10, 1 ); function wc_optional_billing_fields( $address_fields ) { $address_fields[‘billing_address_1’][‘required’] = false; $address_fields[‘billing_address_2’][‘required’] = false; return $address_fields; }…

8 سال پیش

WordPress Hacks

http://wpengineer.com/category/wordpress-hacks/

8 سال پیش

Programmatically Upload Files in WordPress

Programmatically Upload Files in WordPress (and Create Associated Meta Data) Programmatically Upload Files in WordPress (and Create Associated Meta Data)

8 سال پیش

WP_Query inside WP_Query

You can use WP_Query::reset_postdata() for this too. $query = new WP_Query($args); while ($query->have_posts()) : // initialization for $inner_args & backup…

9 سال پیش

WordPress Get Post By Most Views With ViewPost Plugin

<?php $popularpost = new WP_Query(array(‘post_type’=>’magazine’,’posts_per_page’ => 1, ‘meta_key’ => ‘views’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ ) ); while (…

9 سال پیش

Function Reference/wp upload bits

Create a file in the upload folder with given content. $upload = wp_upload_bits($_FILES[“field1”][“name”], null, file_get_contents($_FILES[“field1”][“tmp_name”]));  

9 سال پیش