Why use foreach to get attachment_id if numberposts is equal to 1?

get_children will return an associative array of posts […] with post IDs as array keys, or an empty array if no posts are found. This statement $attachment_id => $attachment is the same as the more commonly used $key => $value. Using this command echo ‘<pre>’.print_r($attachments,true).'</pre>’; we get the following: resumed version of a get_children with … Read more

the post thumbnail, scale

This should work: You could use: add_image_size( ‘category-thumb’, 220, 9999 ); //220 pixels wide (and unlimited height) and then to display: if ( has_post_thumbnail() ) { the_post_thumbnail( ‘category-thumb’ ); } This will create a thumbnail size of 220 by “unlimited”… Set the featured image on the post, then use the display code in your theme … Read more

How can I find the first post in a category that has a featured image and then return the get_the_post_thumbnail()?

The ID of the featured image is stored under the meta key _thumbnail_id, so we can do a query for a single post that has this key: $args = array( ‘posts_per_page’ => 1, ‘meta_key’ => ‘_thumbnail_id’, ‘cat’ => $cat_id ); $latest_thumb = new WP_Query( $args ); if( $latest_thumb->have_posts() ) return get_the_post_thumbnail( $latest_thumb->post->ID );

Can this be done? Create 50×50 thumbnails of all existing featured images?

There are lots of plugins that do this one way or another including: http://wordpress.org/extend/plugins/regenerate-thumbnails/ http://wordpress.org/extend/plugins/dynamic-image-resizer/ I wouldn’t recommend reinventing the wheel. If you’re particularly worried about it, you might looking into TGM Plugin Activation to suggest to people in the Dashboard that they install and use the plugin.

hrecipe microformat tag to “featured image”

Use the filter post_thumbnail_html. The callback takes 5 parameters, the first ($html) is the one that’s returned and that we modify, and the others can be helpful to build the modification. add_filter( ‘post_thumbnail_html’, ‘add_tag_to_featured_wpse_95469’, 10, 5 ); function add_tag_to_featured_wpse_95469( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $modify = str_replace( ‘<img’, ‘<img itemprop=”photo”‘, $html ); return … Read more

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