You are here:  » Setting featured image


Setting featured image

Submitted by richard on Fri, 2017-05-12 14:58 in

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

Submitted by support on Sat, 2017-05-13 10:31

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

Submitted by richard on Sat, 2017-05-13 11:34

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

Submitted by support on Mon, 2017-05-15 08:25

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

Submitted by babrees on Sun, 2017-09-03 18:01

Hi David

Was a workaround found for this?

Cheers
Jill

Submitted by babrees on Mon, 2017-09-04 06:37

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

Submitted by support on Mon, 2017-09-04 09:42

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

Submitted by babrees on Mon, 2017-09-04 10:07

Thanks David! That sounds great and opens up a lot of other possibilities for me! I'll give it a whirl later.

Submitted by babrees on Tue, 2017-09-05 06:02

Unfortunately that doesn't seem to work. Any ideas? I have triple checked that I have the field name correct.

Submitted by support on Tue, 2017-09-05 10:49

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

Submitted by babrees on Tue, 2017-09-05 14:12

PERFECTO! Thank you David!

Submitted by babyuniverse on Sat, 2018-01-20 03:52

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

Submitted by support on Sat, 2018-01-20 09:48

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

Submitted by babyuniverse on Sun, 2018-01-21 00:10

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

Submitted by babyuniverse on Sun, 2018-01-21 00:11

Sorry - can merchant logo also be imported at the time, maybe saved as a custom field.

Submitted by support on Mon, 2018-01-22 09:16

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

Submitted by babyuniverse on Wed, 2018-06-13 09:04

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

Submitted by babyuniverse on Wed, 2018-06-13 09:25

Also any idea on importing the description as wordpress excerpt?

Submitted by support on Wed, 2018-06-13 11:02

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

Submitted by alexnn on Fri, 2018-08-24 10:18

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.

Submitted by support on Fri, 2018-08-24 10:48

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