![]() |
|
Home | Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]() I am using a theme which utilizes the featured image functionality in WP. Currently, I have to go in and edit each post to upload and add the featured image to the post. Anyone have an easier way to accomplish this?
|
#2
|
||||
|
||||
![]() You should be able to edit your template and access a different custom field. You will need to access the field store_image in order to display a product's image.
Here's more about editing your template and displaying custom field values: http://codex.wordpress.org/Custom_Fields Eric
__________________
![]() ![]() ![]() ![]() |
#3
|
|||
|
|||
![]() If it is to show thumbnails on excerpt pages have a look at a plugin called "Thumbnail For Excerpts"... it looks in your post and adds an image (if found) to the excerpt page automatically...
__________________
WordPress Security - Is your WordPress secure? Get our FREE checklist and find out. Easy-Email - Access ALL your email accounts with one login & synchronize automatically on all your computers. |
#4
|
|||
|
|||
![]() Hi Eric,
Could you give a little bit more info on how to do this. The link to wordpress.org you supplied gives quite a complex solution. I need a featured image for each of my drip posts as well. I presume this is a common request. Thanks, |
#5
|
||||
|
||||
![]() I'm not quite sure what you need.... The "Featured Image" feature of WP Posts is not related to the custom field value. It's another value and I have no idea how to make the "Featured Image" field pull from a Custom Field value.
__________________
![]() ![]() ![]() ![]() |
#6
|
|||
|
|||
![]() OK, but do you think (in theory) it's possible? If so I will use the link you provided and try to find a solution.
|
#7
|
||||
|
||||
![]() Hi
In theory, anything is possible. I'm not trying to be flip about that. But, you might have to write a plugin which accomplishes what you are trying to do or you might have to hack core WP code. I have never really hacked around with the Featured Image feature so I'm not sure where to start but I guess I would start with googling about it. Eric
__________________
![]() ![]() ![]() ![]() |
#8
|
|||
|
|||
![]() Hi Eric,
Here is what I used to fix this up in my site if it's useful for other users. Paste the code below into the functions.php file. The uploads folder needs to be writable (permissions 777) and the hosting server Must Support file_get_content/fopen/fputs: function postmeta_img_update() { global $post; // If Custom Post Meta Field for a Image/Thumnail Exists if( get_post_meta($post->ID, "store_image", true) ): // Get Image Location and File Extention $img = get_post_meta($post->ID, "store_image", true); $ext = substr(strrchr($img,'.'),1); // WordPress Upload Directory to Copy to (must be CHMOD to 777) $uploads = wp_upload_dir(); $copydir = $uploads['path']."/"; // Code to Copy Image to WordPress Upload Directory (Server Must Support file_get_content/fopen/fputs) $data = file_get_contents($img); $filetitle = strtolower(str_replace(array(' ', '-', '.', '(', ')', '!', '@', '#', '$', '%', '^', '&', '*', '_', '=', '+'), "-", get_the_title())); $file = fopen($copydir . "$filetitle-$post->ID.$ext", "w+"); fputs($file, $data); fclose($file); // Insert Image to WordPress Media Libraby $filepath = $uploads['path']."/$filetitle-$post->ID.$ext"; $wp_filetype = wp_check_filetype(basename($filepath), null ); $attachment = array( 'post_mime_type' => $wp_filetype['type'], 'post_title' => get_the_title(), 'post_content' => 'Image for '.get_the_title(), 'post_status' => 'inherit' ); wp_insert_attachment($attachment, $filepath, $post->ID); // Get Attachment ID for Post global $wpdb; $attachment_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1"); // Attached Image as Featured Thumbnail in Post update_post_meta($post->ID, "_thumbnail_id", $attachment_id); // Removes Custom Meta Field Image URL. This stop this function running again for the updated post. delete_post_meta($post->ID, "image"); endif; } add_action('the_post','postmeta_img_update'); Cheers |
#9
|
||||
|
||||
![]() Thanks for sharing, Reson8!
__________________
![]() ![]() ![]() ![]() |
#10
|
|||
|
|||
![]() Reason8, thanks but isn't there something more simple than this, I'm trying it now but if you look at for example two themes, twentyten 1.1 and pagelines platform, set reading to latest posts, images show in twenty ten but not platform, why I don't know and I think this is thumbnail related.
Furthermore, when using your php in functions, the images are far too big and break the post but getting host to change access now, is there a way of getting DFR images whether external or uploaded to site to work with the vast array of plugins automatically? For instance sliders etc. I just want the images from dripped posts to show up as visual is obviously more appealing. And Eric, Hello, I do enjoy this product but is there not an easier way to get images to show? I am using the 'special recent posts' plugin and thanks to reason8, images will work in that but is this possibly something you can consider making automatic in DFR please? Ability to make images easily used within a wp theme. If reason8 enables 'featured posts slideshow' to work also then even better as I've spent hours on this tonight. Thanks Lee |
#11
|
||||
|
||||
![]() Hi Lee
You can post feature requests here: http://www.datafeedr.com/forums/forumdisplay.php?f=69 Eric
__________________
![]() ![]() ![]() ![]() |
#12
|
|||
|
|||
![]() Reson8, when you say host must accept fopen, do you mean
allow_url_fopen On On in phpinfo.php as I'm getting some errors and site seems slower (platform theme) functions.php dump |
#13
|
|||
|
|||
![]() Reson8,
Your code does just what you said it does, but unfortunately, it slows down my site to where it take 30 seconds for pages to load. Have you noticed any performance issues after inserting this code? Also, the featured images are very large, and if I click on it in the WP post page, and look in media gallery, there seems to be over 20 of the same image. Don't know if any of this is related... What do you think? Al Quote:
|
#14
|
||||
|
||||
![]() Hi,
Here's the updated code which goes in your theme's functions.php file. I've only tested that it works... it has not been tested for security or anything else. Use at your own risk! PHP Code:
__________________
![]() ![]() ![]() ![]() |
#15
|
|||
|
|||
![]() It works! Thank you!
|
#16
|
|||
|
|||
![]() Hi, do I copy that code anywhere inside my functions.php file? Do I enclose this code with any other code? I really would love for this to work, to get creative with datafeedr, most plugins, use the featured image.
Thank You |
#17
|
||||
|
||||
![]() Hi,
That code should go at the bottom of your theme's functions.php file. This can sometimes be tricky. Make sure it appears before the final line that contains ?> Eric
__________________
![]() ![]() ![]() ![]() |
#18
|
|||
|
|||
![]() Hi Eric, is this what the server needs to be able to do this - allow_url_fopen = On - for some reason, some pictures loaded fine, and some did not load, after I placed the code.
thank you |
#19
|
||||
|
||||
![]() Hi,
No, that code doesn't require allow_url_fopen... at least I don't see use of that function in the code. That code requires: file_get_content() fopen() fputs() However, some pictures might not load fine on your site because the merchant has blocked the remote downloading of their images. There's not much you can do about that... Eric
__________________
![]() ![]() ![]() ![]() |
#20
|
|||
|
|||
![]() Hi Eric thank you for the prompt response, I think that might be the case, is there a way to filter stores, based on remote download capabilities?
|
Thread Tools | Search this Thread |
Display Modes | |
|
|