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; 
  • The following code has nothing to do with guid. In addition, it is impossible to write guid functions of WP - there are none. Only by "manually" writing the field to the database. Please state what is bothering you on the page? Show how you bring custom_type to the page and what doesn’t suit the resulting html. - KAGG Design
  • > The above code has nothing to do with the guid. - word
  • How is this irrelevant ?! I said that if you remove the post_type_link hook, then completely different information is written in the guid field - word
  • added a question - word
  • and how do you check that in the guid? and what information is there in case of 1 and in case of 2? - KAGG Design

0