Tag Info

Hot answers tagged

3

As of 4.1.1, the nonce is defined in wp-includes/media.php, line 2883: $settings['post'] = array( 'id' => $post->ID, 'nonce' => wp_create_nonce( 'update-post_' . $post->ID ), ); So to verify the nonce: wp_verify_nonce( $nonce, "update-post_$post_ID" );


2

I've spent hours of research and found the solution a few minutes after writing this question: $args = array( 'post_type' => 'attachment', 'post_status' => 'inherit', <<-- IMPORTANT 'meta_query' => array( array( 'key' => 'medientyp', 'value' => 'Video' ) ) ); $query ...


1

Use the add_attachment hook to update the slug after the attachment has been inserted: function wpse_182454_attachment_id_as_slug( $post_id ) { if ( get_post_field( 'post_name', $post_id ) != $post_id ) { wp_update_post( array( 'ID' => $post_id, 'post_name' => ( string ) $post_id, ) ...


1

WordPress doesn't store path of generated sizes anywhere, you need to build it. As suggested by @kraftner in comments, wp_get_attachment_metadata() can be used to obtain some of the pieces you need to build the path. An alternative is image_get_intermediate_size(). The missing piece is the absolute path of upload folder. In theory, that can be retrieved ...


1

Try this in the foreach loop: $thumb_url = wp_get_attachment_image_src( $attachment->ID, 'full' ); And this for the img src: echo $thumb_url[0];


1

So since attachments are post types, you should be able to assign them postmeta like any other post type. Using the update_post_meta function should get you where you need to be. update_post_meta( $attachment_id, 'price', $price ); http://codex.wordpress.org/Function_Reference/update_post_meta Then run your query based on a meta key. $args = array( ...


1

I think what you are after is get_post_meta() and not a custom query. REASONS: The results from custom fields are cached and extremely streamline when it cone to performance. You can read this answer I have done recently which will explain everything You are trying to get the custom field attached to a post only in a single post page. This is what ...



Only top voted, non community-wiki answers of a minimum length are eligible