i found this nice snippet on the web but because i don`t know php i need some help. This code extract the attached picture from post and display it as a shortcode but i want to make it generate thumbs automaticaly on my first page. function cwc_postimage($atts, $content = null) { extract(shortcode_atts(array( "size" => 'thumbnail', "float" => 'none' ), $atts)); $images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . get_the_id() ); foreach( $images as $imageID => $imagePost ) $fullimage = wp_get_attachment_image($imageID, $size, false); $imagedata = wp_get_attachment_image_src($imageID, $size, false); $width = ($imagedata[1]+2); $height = ($imagedata[2]+2); return '<div class="postimage" style="width: '.$width.'px; height: '.$height.'px; float: '.$float.';">'.$fullimage.'</div>'; } add_shortcode("postimage", "cwc_postimage"); Code (markup): and "[postimage]" is the shortcode to display the image i use "thumb" as custom field for images. any ideas how can i do it?
Does [postimage] call anything when you use it? Add this somewhere into your themes functions.php file and it should turn on.
i don`t want to use [postimage] (the shortcode), in my first page show the pics with "thumb" at custom field ... i need someting like above code = thumb
What do you mean by this: " i need someting like above code = thumb" Does the shortcode work when you use it in content. Why post the shortcode code if you are not looking to use the shortcode?
this thing function cwc_postimage($atts, $content = null) { extract(shortcode_atts(array( "size" => 'thumbnail', "float" => 'none' ), $atts)); $images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=' . get_the_id() ); foreach( $images as $imageID => $imagePost ) $fullimage = wp_get_attachment_image($imageID, $size, false); $imagedata = wp_get_attachment_image_src($imageID, $size, false); $width = ($imagedata[1]+2); $height = ($imagedata[2]+2); return '<div class="postimage" style="width: '.$width.'px; height: '.$height.'px; float: '.$float.';">'.$fullimage.'</div>'; } add_shortcode("postimage", "cwc_postimage"); Code (markup): ============ (equal) thumb Code (markup): this code "unction cwc_postimage ....." extract latest attached image from the post ... and i want to use it to display posts thumbs on my first page. i don`t want to modify template and to put [postimage] in the index.php file. my thumbs have "thumb" on custom fields (i need to copy image url and paste it in the custom fileds -> below posts in wp dashbord) and i heeded help to modify that code and add "thumb" automaticaly on image.
Before I help you any further, have your tried the thumbnail to excerpts plugin? http://wordpress.org/extend/plugins/thumbnail-for-excerpts/
So it looks like "and i want to use it to display posts thumbs on my first page. i don`t want to modify template and to put [postimage] in the index.php file. " is exactly what you need to do though. Why don't you want to add this shortcode forcibly to the template?
you are acting like the police ... too many questions ... if somebody else can help me i`ll be glad ...
Yes yes need to know reasons to give best solutions. I do not care what you are doing though, just wondering why it is bad to modify the template in your case, so I am surprised at your response. You could use an ad injection plugin like WP Traffic Tools or possible a free one like Ad Injection to auto-insert the shortcode somewhere in your post without modifying the theme code.
ok .. i`m sorry for that ... but as i told before i`m a newbie .. i dont know php and css ... and when i tryed last time to change something didn`t work as planned ... and i saw that piece of code that i need to put in function.php ... thats easy ...
The ad injection might be your best bet then. This way you can paste the shortcode into the ad template and just insert it into your posts. Ad Injection plugin is free.
ok ... but will appear 2 thumb ... one fro theme and 1 from shartcode ... do you know how to make what i want or you need many posts?
Give it a try and place it above the post content and you should get some feedback and we can work form there. http://wordpress.org/extend/plugins/ad-injection/