Creating a multi-file upload form on the front end for attachments

This may not be the most elegant way to do it (I’m not sure if overwriting the $_FILES global is even allowed) but this seems to work: global $post; if ($_FILES) { $files = $_FILES[‘upload_attachment’]; foreach ($files[‘name’] as $key => $value) { if ($files[‘name’][$key]) { $file = array( ‘name’ => $files[‘name’][$key], ‘type’ => $files[‘type’][$key], ‘tmp_name’ … Read more

How to Make a Categories Meta Box with Hierarchical Checkboxes on Frontend?

Try wp_terms_checklist() / wp_category_checklist. It will output a list of checkboxes named post_category. You might need to include the source file too, because it’s defined within administration files. Or use a custom walker: class MyCategoryWalker extends Walker_Category{ public function start_el(&$output, $term, $depth, $args){ $args = wp_parse_args(array( ‘name’ => ‘my_category_input’, ‘checked’ => array(), ), $args); extract($args); … Read more

Delete attachments from Front end

You can do it via ajax, first, let’s change your current function to this: <?php $args = array( ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’, ‘post_type’ => ‘attachment’, ‘post_parent’ => $post->ID, ‘post_mime_type’ => ‘image’, ‘post_status’ => null, ‘numberposts’ => -1, ); $images = get_posts( $args ); $imagenum=0; foreach($images as $image): $imagenum++; ?> <div style=”width:110px; float:left;”> <?php … Read more

How to link WordPress heartbeat to ajax form

Saving data Based on Heartbeat API, you can add custom data to the sent heartbeat on heartbeat-send event in js. This would be used instead of the ajax function you have in your code example. jQuery( document ).on( ‘heartbeat-send’, function ( event, data ) { // Grab the required form data data.location = jQuery(‘input[name=”location”]:checked’).val(); data.userid … Read more

List custom post types in dropdown

Sorry about that feels a bit weird answering ones own question, but here you go…. Firstly declare the variable: (customcategory) global $userdata; $errors = array(); $title = trim($_POST[‘wpuf_post_title’]); $customcategory = trim($_POST[‘customcategory’]); $content = trim($_POST[‘wpuf_post_content’]); $tags = wpuf_clean_tags($_POST[‘wpuf_post_tags’]); $cat = trim($_POST[‘cat’]); Secondly the array for adding the post: if (!$errors) { $frontend_post = array( ‘post_title’ => … Read more

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