Hi David
Could I get the plugin to insert into a custom post type, rather than the default 'post'?
Cheers
Jill
Thanks David!
Now you know what a pest I am!
What about custom category?
Hi Jill,
The actual post category field is set to the feed category (if not empty) by the following code at beginning at line 287 of pto_common.php:
if ($pto_productResults[0]->category)
{
$post["post_category"] = array(wp_create_category($pto_productResults[0]->category));
}
If you just wanted to set your own, fixed category value for each post then you could REPLACE the above with:
$post["post_category"] = "Custom Category";
On the other hand, if you wanted to set a custom field e.g. "CUSTOM_CATEGORY" to the feed category value, then this can be done by adding another field to the array used as the value for the meta_input field from the modification described here for example:
$post["meta_input"] = array(
"CUSTOM_IMAGE_URL"=>$pto_productResults[0]->image_url,
"CUSTOM_CATEGORY"=>$pto_productResults[0]->category
);
Cheers,
David.
--
PriceTapestry.com
Thanks David.
I'm useless at explaining what I want!
I will have a custom category (taxonomy) type, and want it to behave exactly as it does but to add/use the custom taxonomy instead. In other words, sub-categories created
I hope that's clear LOL!
With your latter example, would that still create sub-categories for my custom-category?
Hi Jill,
Just to clarify, you want posts of have a 2-tier taxonomy of
Your Custom Category > Feed Category
Thanks!
David.
--
PriceTapestry.com
Hi David
So glad you worded it!!!
No. I will just have a custom taxonomy (category-pt), so not 2 tier.
Cheers
Jill
Hi Jill,
No problem! So to set a custom taxonomy of "category-pt" instead of the post category to the feed category value, look for the following code beginning at line 287 of pto_common.php:
if ($pto_productResults[0]->category)
{
$post["post_category"] = array(wp_create_category($pto_productResults[0]->category));
}
...and REPLACE with:
if ($pto_productResults[0]->category)
{
$post["tax_input"] = array("category-pt" => $pto_productResults[0]->category);
}
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi David.
I know this is sometime since you gave me a reply on this, but I'm only just getting around to the site again!!!
I tried your first reply in order to import them to a custom post type, but I can't get it to work. All it does is just import them to the default post type still!
Hello Jill,
Assuming the custom post type you are using is registered that should be all that is required - would you be able to to a test with just a few products but using "page" instead of "post"?
If still not working as expected, if you could email me the modified pto_common.php I'll check it out further with you ...
Cheers,
David.
--
PriceTapestry.com
Hi David,
I actually got the same problem as the previous customer while trying to import as custom type.
I have also tried to import as page, but what I get are post.
Any suggestion?
Regards
Hi,
My apologies there was a mistake in the final modification to pto_common.php described in the first reply in this thread - the new code beginning at line 281:
$post["post_title"] = $post["post_name"];
$post["post_type"] = $post["custom_post_type"];
...should be:
$post["post_title"] = $post["post_name"];
$post["post_type"] = "custom_post_type";
(or "page" instead of "custom_post_type" to test as pages)
Corrected above.
Cheers,
David.
--
PriceTapestry.com
Hi Jill,
Sure - "post" is referred to literally a couple of times in pto_common.php - first look for the following code around line 62:
$retval = get_permalink(get_page_by_title($product->name,"OBJECT","post"));
...and REPLACE with:
$retval = get_permalink(get_page_by_title($product->name,"OBJECT","custom_post_type"));
And then the following code at line 274:
if ($p = get_page_by_title($product->name,"OBJECT","post"))
...and REPLACE with:
if ($p = get_page_by_title($product->name,"OBJECT","custom_post_type"))
And then look for the following code at line 281:
$post["post_title"] = $post["post_name"];
...and REPLACE with:
$post["post_title"] = $post["post_name"];
$post["post_type"] = "custom_post_type";
In all cases above, replace custom_post_type in the replacement code with your custom post type as required...
Cheers,
David.
--
PriceTapestry.com