There is a plugin that parses records from the partner site, and stores these records in a new arbitrary type, say custom_type.
These copied entries are needed only for SEO and to display links to these copied entries, for example, in the sidebar, or under content. And if you click on this link, then there should be a transition to the corresponding record of the partner.
To go to the partner site I use the post_type_link hook
add_filter('post_type_link', 'custom_post_type_link', 1, 2); function custom_post_type_link($link, $post){ if ( $post->post_type == 'custom_type' ){ $partnerLink = get_option('partner_link'); $link = get_post_meta($post->ID, 'link', true); return $partnerLink . $link; } else { return $link; } } Tell me, please, what should be recorded in the guid database field?
Those. if you use the post_type_link hook, then when copying records from the partner site, the guid field will be written like this:
http://partner-site.ru/title-post //$partnerLink . $link and if you remove the post_type_link hook, then when copying to the guid field it will be recorded as usual, depending on the chosen way to display permalinks in the settings.
Tell me how to properly forward and what to write in the guid field of the database?
///////////// The parser uses curl to collect entries from the partner site into an array. Then in a loop from this array, the copied entries are created in the new type custom_type.
//foreach $args = array( 'post_title' => $title, 'post_content' => $content, 'post_type' => 'custom_type', 'post_status' => 'publish', ); if(!($post_id = wp_insert_post(wp_slash($args)))) continue;