Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (class_exists('wpprolister_core')) {
- add_action('wp_insert_post', 'wpprolister_updated_to_publish', 10, 3);
- function wpprolister_updated_to_publish($post_id, $post, $update)
- {
- if (get_field('wpprolister_advanced_option_edit_seo', $post_id)) {
- $metatitle = get_field('wpprolister_seo_title', $post_id);
- $metadesc = get_field('wpprolister_seo_meta_description', $post_id);
- $metakeywords = get_field('wpprolister_seo_keyword', $post_id);
- $content = get_field('wpprolister_description', $post_id);
- $image = get_field('wpprolister_listing_slider_image', $post_id);
- $attachment_id = $image['ID'];
- if (!empty($image)):
- $size = 'medium';
- $thumb = $image['sizes'][$size];
- if (defined('WPSEO_VERSION')) {
- update_post_meta($post_id, '_yoast_wpseo_title', $metatitle);
- update_post_meta($post_id, '_yoast_wpseo_metadesc', $metadesc);
- update_post_meta($post_id, '_yoast_wpseo_focuskw', $metakeywords);}
- //also update the content and featured image
- $my_post = array(
- 'ID' => $post_id,
- 'post_content' => $content,
- );
- wp_update_post($my_post);
- update_post_meta($post_id, '_thumbnail_id', $attachment_id);
- endif;
- }
- }
- }
Add Comment
Please, Sign In to add comment