How to update post’s featured image in front-end
The Front-end Editor plugin allows you to change post thumbnails (featured images).
The Front-end Editor plugin allows you to change post thumbnails (featured images).
Do not use wp_login function it is deprecated , instead use wp_signon. wp_signon function returns WP_Error on failure so use it to evaluate condition as following. <?php if ( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty( $_POST[‘action’] ) && $_POST[‘action’] == ‘log-in’ ) : $login = wp_signon( array( ‘user_login’ => $_POST[‘user-name’], ‘user_password’ => $_POST[‘password’], ‘remember’ => $_POST[‘remember-me’] … Read more
I don’t have time for a detailed reply but some ideas: 1) Use arrays in the front end. Make your input ID’s like add_task_assigned[] and add_task_complete[] – these appear as arrays in the back end. It’s not great practice, but it works. 2) Use an array in the backend. Store the meta as array( [0] … Read more
In case anyone needs this, here is my solution: if ($_FILES) { function insert_attachment($file_handler, $post_id, $setthumb = ‘false’) { if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) __return_false(); require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); $attach_id = media_handle_upload( $file_handler, $post_id ); //get url $attachment_url = wp_get_attachment_url($attach_id); add_post_meta($post_id, ‘_file_paths’, $attachment_url); $attachment_data = … Read more
echo wp_editor to screen with formatting
WordPress Front end editor
Getting values from database with delay
For anyone else looking for guidance on how to do this, I created another custom field called event_status and by using the save_post action in wordpress set a condition that once this changes to then the run delete_post_meta action as follows: function event_status_is_updated($post_id){ if(get_post_meta($post_id,’event_status’,true)==’not_complete’){ delete_post_meta($post_id,’date_dun’); } } add_action(‘save_post_event’,’event_status_is_updated’);
You can hook pre_get_posts and use the order_by argument of WP_Query. From a plugin or functions.php of active theme, something like the following (untested example): add_action( ‘pre_get_posts’, ‘my_post_type_sort’, 10, 1); function my_post_type_sort( $query ) { if ( is_admin || ! $query->is_main_query() ) { return; } if ( $query->get(‘post_type’) !== ‘name_of_post_type’ ) { return; } $query->set(‘orderby’, … Read more
Don’t open edit post link in new tab