<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Relations &#8211; Coding Chicken</title>
	<atom:link href="https://codingchicken.com/docs-category/relations/feed/" rel="self" type="application/rss+xml" />
	<link>https://codingchicken.com</link>
	<description>Building Awesome Things for WordPress</description>
	<lastBuildDate>Mon, 22 Jan 2024 15:56:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Relations</title>
		<link>https://codingchicken.com/docs/relations/</link>
					<comments>https://codingchicken.com/docs/relations/#respond</comments>
		
		<dc:creator><![CDATA[chyland]]></dc:creator>
		<pubDate>Mon, 22 Jan 2024 15:54:41 +0000</pubDate>
				<guid isPermaLink="false">https://codingchicken.com/?post_type=docs&#038;p=542</guid>

					<description><![CDATA[When importing relations, the relation you want to match must already exist. Otherwise, import it first then run the import that will link the two objects. If a limit is set on the number of set relations then the oldest relation pair will be replaced with the latest relation pair as they&#8217;re imported. By default, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<p>When importing relations, the relation you want to match must already exist. Otherwise, import it first then run the import that will link the two objects. </p>



<p>If a limit is set on the number of set relations then the oldest relation pair will be replaced with the latest relation pair as they&#8217;re imported. </p>



<p>By default, existing relations are first removed and then recreated each time the import runs. </p>
</div></div>



<p><strong>You must use the &#8216;Set with XPath field to provide the related object ID: </strong></p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="348" src="https://codingchicken.com/wp-content/uploads/2024/01/image-1024x348.png" alt="" class="wp-image-543" srcset="https://codingchicken.com/wp-content/uploads/2024/01/image-1024x348.png 1024w, https://codingchicken.com/wp-content/uploads/2024/01/image-300x102.png 300w, https://codingchicken.com/wp-content/uploads/2024/01/image-768x261.png 768w, https://codingchicken.com/wp-content/uploads/2024/01/image-1536x521.png 1536w, https://codingchicken.com/wp-content/uploads/2024/01/image-2048x695.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>The object ID is required and must be the ID as it&#8217;s stored in WordPress (Post ID, User ID, CCT ID, etc). It&#8217;s required that you provide these IDs explicitly due to the vast number of different object types which can be configured for use in relations. <br><br>With WP All Import&#8217;s ability to run custom code, you can often automate some of that ID translation though: <a href="https://www.wpallimport.com/documentation/inline-php/" target="_blank" rel="noreferrer noopener">https://www.wpallimport.com/documentation/inline-php/</a></p>



<p>Here&#8217;s a brief example showing how you might get the IDs for a custom post type&#8217;s records when matching by Title: </p>



<p><strong>Function Editor example: </strong></p>



<pre class="wp-block-code"><code><em>function my_get_destination($title){
    $destination = wp_all_import_get_page_by_title($title,"destination");

    return $destination->ID ?? '';
}</em></code></pre>



<p><strong>Called with:</strong></p>



<pre class="wp-block-code"><code>&#91;my_get_destination({YourFieldElement&#91;1]})]</code></pre>



<p><strong>In action: </strong></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="607" src="https://codingchicken.com/wp-content/uploads/2024/01/image-1-1024x607.png" alt="" class="wp-image-544" srcset="https://codingchicken.com/wp-content/uploads/2024/01/image-1-1024x607.png 1024w, https://codingchicken.com/wp-content/uploads/2024/01/image-1-300x178.png 300w, https://codingchicken.com/wp-content/uploads/2024/01/image-1-768x456.png 768w, https://codingchicken.com/wp-content/uploads/2024/01/image-1.png 1067w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://codingchicken.com/docs/relations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
