Hi David,
I'm just playing with V3 for wordpress. So far no issues and appears to be very easy to use, thank you :)
How would you set a featured image for each imported post?
Best regards,
Richard
Hi David,
When creating a manual post in wordpress, there is an option on the right hand side of the screen to select an image that you would like to use as a featured image. This is ideal if you want to use a different image to that used in the post.
Many thanks,
Best regards
Richard
Thanks Richard,
I'll check this out on my test server - a quick look suggests the image needs to be present in the media library but it may be possible to inject dynamically via filters - I'll check it out but unfortunately it doesn't look as if it would be as straight forward as setting another field in the $post array when creating the post...
Cheers,
David.
--
PriceTapestry.com
Hi David
Was a workaround found for this?
Cheers
Jill
Hi David
If it's not possible to have it as a WP featured image, is it possible to inject it into a custom field? I can easily create a custom field for it.
Cheers
Jill
Hello Jill,
It's straight forward to set a custom field (post meta data) with the image_url value. To do this, edit pto_common.php and look for the following code at line 285:
$post["post_status"] = "publish";
...and REPLACE with:
$post["post_status"] = "publish";
$post["meta_input"] = array("CUSTOM_IMAGE_URL"=>$pto_productResults[0]->image_url);
(where CUSTOM_IMAGE_URL is the custom field name you wish to hold the image_url value)
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Thanks David! That sounds great and opens up a lot of other possibilities for me! I'll give it a whirl later.
Unfortunately that doesn't seem to work. Any ideas? I have triple checked that I have the field name correct.
Hello Jill,
Sorry about that - $product should be $pto_productResults[0] in the replacement code - corrected above as:
$post["post_status"] = "publish";
$post["meta_input"] = array("CUSTOM_IMAGE_URL"=>$pto_productResults[0]->image_url);
Cheers,
David.
--
PriceTapestry.com
Im using $post["meta_input"] = array("CUSTOM_IMAGE_URL"=>$pto_productResults[0]->image_url); to add the image_url to a custom field on import which is working.
I tried similar for buy_url using the following
$post["post_status"] = "publish";
$post["meta_input"] = array("fifu_image_url"=>$pto_productResults[0]->image_url);
$post["meta_input"] = array("rehub_offer_product_url"=>$pto_productResults[0]->buy_url);
It seems to work for the buy_url now but the image has stopped working.
What I would like to do is captor the following as custom fields on import.
price
image_url
product_name
brand
description
Thanks
Richard
Hello Richard,
Set by actual key rather than using array(), for example:
$post["meta_input"]["fifu_image_url"] = $pto_productResults[0]->image_url;
$post["meta_input"]("rehub_offer_product_url"] = $pto_productResults[0]->buy_url;
// etc.
Cheers,
David.
--
PriceTapestry.com
Thanks worked perfectly.
Along the same lines, i am looking to import brand as a custom taxonomy in wordpress called brands.
I'm assuming it can be imported the same way categories can.
Regards
Richard
Sorry - can merchant logo also be imported at the time, maybe saved as a custom field.
Hi Richard,
To populate the custom taxonomy "brands" should just be:
if ($pto_productResults[0]->brand)
{
$post["tax_input"]["brands"] = $pto_productResults[0]->brand;
}
And for custom field "merchant_logo", have a go with:
global $pto_config_externalBaseHREF;
global $pto_config_logoExtension;
$merchant_logo = $pto_config_externalBaseHREF."logos/".str_replace(" ","%20",$pto_productResults[0]->merchant).$pto_config_logoExtension;
$post["meta_input"]["merchant_logo"] = $merchant_logo;
Cheers,
David.
--
PriceTapestry.com
Hi David,
Hope you are well,
For some reason the following is not working
if ($pto_productResults[0]->brand)
{
$post["tax_input"]["brands"] = $pto_productResults[0]->brand;
}
if ($pto_productResults[0]->merchant)
{
$post["tax_input"]["stores"] = $pto_productResults[0]->merchant;
}
I have 2 custom taxonomies called brands and stores and it doesn't seem to populate. I can see brand in the original datafeed and it seems to be mapped correctly.
THanks
Richard
Also any idea on importing the description as wordpress excerpt?
Hi Richard,
Please could you email me the modified file so that I can see the code in context and I'll check it out further with you...
Cheers,
David.
--
PriceTapestry.com
Hi David,
I searched the forum, but did not find the answer
How do I set a WP featured image for posts using pt "image_url"?
I would like to get featured image in post after imported.
Hello Alex,
Featured image (thumbail) is on the wish list - it's not straight forward as the image has to come from the media library rather than a URL but I'll investigate the options on my test server and update this thread / along with the next distribution if it's going to be practical...
Cheers,
David.
--
PriceTapestry.com
Hello Richard,
Thank you for your comments!
By featured image, do you mean having control over which merchant's image is chosen as the image that is used (rather than just that of the cheapest merchant)?
Cheers,
David.
--
PriceTapestry.com