Control attachments menu order with jQuery Sortable

To save the menu order use wp_update_post() with each attachment ID and its new menu position: $thisattachment = array(); $thisattachment[‘ID’] = $thisid; $thisattachment[‘menu_order’] = $new_menu_position; wp_update_post($thisattachment); EDIT – assuming these are already attachments and you’re updating them? Otherwise you have to insert the attachments first with wp_insert_attachment

How do I link an image to the post it is attached to?

After some additional searching I was able to come across a function to generate the attachment ID here: http://pippinsplugins.com/retrieve-attachment-id-from-image-url/: // retrieves the attachment ID from the file URL function pippin_get_image_id($image_url) { global $wpdb; $prefix = $wpdb->prefix; $attachment = $wpdb->get_col($wpdb->prepare(“SELECT ID FROM ” . $prefix . “posts” . ” WHERE guid='” . $image_url . “‘;”)); return … Read more

Where does the gallery shortcode gets its attachments from?

This completely depends on how your gallery shortcode looks like. If you replaced it with something custom, then you’ll have to take a look at the plugin (or the theme). The default gallery shortcode gets it from a query: $query_args = array( ‘post_status’ => ‘inherit’ ,’post_type’ => ‘attachment’ ,’post_mime_type’ => ‘image’ ,’order’ => $order ,’orderby’ … Read more

Image Gallery Numbers for 3.5

There is no complete solution possible. And that is not new. Any image can be a part of a gallery in a post that is not that image’s parent. So the post parent is not a useful parameter. The new interface makes such galleries easier to create, but they were possible in earlier versions too. … Read more

Import Attachments – not attaching to post_parent

I think that importing attachments separately (which is not possible with native export) is precisely cause for your issue. Importer plugin has following code: if ( $post_parent ) { // if we already know the parent, map it to the new local ID if ( isset( $this->processed_posts[$post_parent] ) ) { $post_parent = $this->processed_posts[$post_parent]; // otherwise … Read more

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