Tag Info

New answers tagged

0

Use these: get_post_meta($attachment->ID, '_title_en', true); get_post_meta($attachment->ID, '_description_en', true); get_post_meta($attachment->ID, '_title_es', true); get_post_meta($attachment->ID, '_description_es', true); See if you need to use the _ prefix: Creating Custom Fields for Attachments in Wordpress Also: Function Reference/get ...


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

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, ) ...


0

You need to add the query before the actualy displaying of the div, then you can run your conditional. According to get_posts() it returns an array, so I'm assuming it returns an empty array if posts aren't found, thus we can check is it's not ! empty() <?php $args = array( 'post_type' => 'attachment', 'orderby' => 'menu_order', ...


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

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

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];


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" );


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 ...


0

That's because wp_mail expects the attachment to be a filename (filepath) that it can attach and send. You are supplying a string containing the contents of the file: function create_csv() { $filepath = '/path/to/the/file.csv'; $fd = fopen($filepath, 'w'); if($fd === FALSE) { die('Failed to open temporary file'); } $records = ...



Top 50 recent answers are included