Anonymous User
(@anonymized-3085)
in 3.1 you would be able to use: set_post_thumbnail to automatically set it.
But have a look at the function get_the_post_thumbnail and specifically the filter post_thumbnail_html, which might be useful.
Hey Rich, thanks for the feedback! Here’s what I’m trying to do, and I’ve tried to modify the eshop-base.php files, etc. I want to replace the calls for the featured thumbnail, everywhere eshop is looking for the post thumbnail, i want it to use this snippet of code instead:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Thumbnail', true);
?>
That will grab the custom field (which has the thumbnail URL) and put it in the Google Base XML. If I could only modify the files correctly! Any tips?
Thanks!
Ok, got it! So, here are instructions to add a custom field value to the eShop Google base feed: (I’ll be using it to add an image link, and to add a different brand for each item)
1. Open eshop-base-feed.php.
2. Up top somewhere, add this code:
global $wp_query;
$postid = $wp_query->post->ID;
$imagelinkcustom = get_post_meta($postid, 'Thumbnail', true);
It defines the variable $imagelinkcustom from the custom field “Thumbnail”. Replace “Thumbnail” with the name of the custom field you want to grab.
3. Replace lines 107-111 with this:
<item>
<link>'.eshoprssfilter($baselink).'</link>
<title>'.eshoprssfilter($basetitle).'</title>
<description>'.eshoprssfilter($basedescription).'</description>
<g:id>'.eshoprssfilter($baseid).'</g:id>
<g:image_link>'.$imagelinkcustom.'</g:image_link>';
The key part of the above code is this line:
<g:image_link>'.$imagelinkalan.'</g:image_link>
But it’s a little tricky to get the apostrophes right, so you can just paste the whole thing. 🙂
Nevermind! The code doesn’t quite work. It does not cycle through all the wordpress posts, it just used the custom field value from the first post. I guess you’d have to do a for each scenario on it? I’m not sure how eshop-base-feed.php loops through the products. Rich, would you have any suggestions? This is what I have now for defining the variables $imagelink and $brand. I guess it’s not a constant variable, it needs to be an array of products, but I can’t figure out how to insert this whole mess inside the<item> template you’ve laid out.
global $wp_query;
$postid = $wp_query->post->ID;
$imagelink = get_post_meta($postid, 'Thumbnail', true);
global $wp_query;
$postid = $wp_query->post->ID;
$brand = get_post_meta($postid, 'brand', true);