Front end post and upload file, image for users without plugin

Use wp_handle_upload in a custom function if ( $_FILES ) { upload_user_file($_FILES[‘test_upload’]); } if ( ! function_exists( ‘upload_user_file’ ) ) : function upload_user_file( $file = array(), $title = false ) { require_once ABSPATH.’wp-admin/includes/admin.php’; $file_return = wp_handle_upload($file, array(‘test_form’ => false)); if(isset($file_return[‘error’]) || isset($file_return[‘upload_error_handler’])){ return false; }else{ $filename = $file_return[‘file’]; $attachment = array( ‘post_mime_type’ => $file_return[‘type’], ‘post_content’ … Read more

Display custom meta on page that has been check in custom post type

You just want a meta_query based on the current page’s ID: $query = new WP_Query( array( ‘post_type’ => ‘sidebar_boxes’, ‘posts_per_page’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘key’ => ‘checkfieldBox’, ‘value’ => $post->ID, ) ) ); You can really only depend upon $post in the way I did on “singular” pages … Read more

Woocommerce frontend edit custom fields

you don’t have to edit the order-details.php page the woocommerce_order_details_after_order_table action will achieve the same results. add_action( ‘woocommerce_order_details_after_order_table’, ‘namespace\custom_field_display_cust_order_meta’, 10, 1 ); function custom_field_display_cust_order_meta( $order ) { echo ‘<form [whatever]>’; /* translators: whatever */ echo ‘<p>’ . sprintf( __( ‘<strong>Property 1:</strong> %1$s (%2$s)’ ), ‘<input [whatever]>’ . get_post_meta( $order->get_order_number(), ‘property 1.1’, true ) . ‘</input>’, … Read more

Get Post ID after front end post submission

wp_insert_post() returns either one of three things the newly created post’s ID a WP_Error object if $wp_error is set to true if an error occured during post insertion in which case the post is not inserted 0 if $wp_error is set to false (default) if an error occured during post insertion in which case the … Read more

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