0

All I want to do is get Wordpress's featured image XML code to use a jpeg link as the meta_value, instead of the image gallery data-id number.

Basically change this code:

<wp:postmeta> 
        <wp:meta_key><![CDATA[_thumbnail_id]]></wp:meta_key>
        <wp:meta_value><![CDATA[202466]]></wp:meta_value>
</wp:postmeta>

To something reading like this:

<wp:postmeta> 
        <wp:meta_key><![CDATA[_thumbnail_id]]></wp:meta_key>
        <wp:meta_value><![CDATA[http://xxxx.com/wp-content/uploads/xxxx.jpg]]></wp:meta_value>
</wp:postmeta>

I appreciate the help, hopefully its something simple enough.

3
  • "use a jpeg link as the meta_value, instead of the image gallery data-id number" - how did you code the number? Are you talking about an XML file you generated/coded yourself? If not, how is it generated - using a plugin?
    – Sally CJ
    Jan 20, 2022 at 8:26
  • Hi, Sally, Im guessing your're new too. The id is generated from the wordpress export function; which generates the XML. Use the link below, putting in your site name. -- yourWordpressSiteName.com/wp-admin/export.php
    – fhonics
    Jan 20, 2022 at 9:11
  • 1
    @sally, I actually solved it. I will post in a bit.
    – fhonics
    Jan 20, 2022 at 13:28

1 Answer 1

0

You have to post two "items" in the xml. The first item is the "parent" portfolio-item... and the second is the attachment linking to the parent item. See below the entire XML rss. (I excluded all the information within the "item tag" which was not specific to this question to keep the answer light and easier to follow).

After writing this, upload the XML file using WordpressDashboard>>Tools>>import or (http://yourSite.com/wp-admin/import.php) Make certain you import checking the "Download/Import images" checkbox.

<rss>

<channel>
    <title>Portfolio-item Name</title>
    <link>http://example.com</link>
    <description>xxxxx</description>
    <pubDate></pubDate>
    <language>en-US</language>
    <wp:wxr_version>1.2</wp:wxr_version>
    <wp:base_site_url>http://example.com</wp:base_site_url>
    <wp:base_blog_url>http://example.com</wp:base_blog_url>


    <generator>https://wordpress.org/?v=5.8.3</generator>

<item>
<wp:post_id>1111111</wp:post_id>
<wp:postmeta> 
        <wp:meta_key><![CDATA[_thumbnail_id]]></wp:meta_key>
        <wp:meta_value><![CDATA[2222222]]></wp:meta_value>
</wp:postmeta>
</item>

Simultaneously add the attachment item which links via the id(number) you assign: In this case im using 2222222 as the image id.

<item>
<title><![CDATA[xxxxxxx.jpegName]]></title>
<wp:post_name><![CDATA[xxxxxxx.jpg]]></wp:post_name>
<dc:creator><![CDATA[]]></dc:creator>

    <link>http://example.com/?attachment_id=1111111</link>
    <wp:post_id>2222222</wp:post_id>
    <wp:status><![CDATA[inherit]]></wp:status>
    <wp:post_parent>1111111</wp:post_parent>
    <wp:post_type><![CDATA[attachment]]></wp:post_type>
    <wp:attachment_url><![CDATA[http://example.com/xxxxx.jpg]]></wp:attachment_url>
    
    <wp:postmeta>
    <wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
    <wp:meta_value><![CDATA[xxxxxxx.jpg]]></wp:meta_value>
    </wp:postmeta>    
</item>


</channel>
</rss>

Hope this helps. It was difficult to find this, but I sorted it out, hopefully it will help another newbie like myself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.