Guest User

Untitled

a guest
Jan 23rd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. if (class_exists('wpprolister_core')) {
  2.  
  3. add_action('wp_insert_post', 'wpprolister_updated_to_publish', 10, 3);
  4.  
  5. function wpprolister_updated_to_publish($post_id, $post, $update)
  6. {
  7.  
  8. if (get_field('wpprolister_advanced_option_edit_seo', $post_id)) {
  9.  
  10. $metatitle = get_field('wpprolister_seo_title', $post_id);
  11. $metadesc = get_field('wpprolister_seo_meta_description', $post_id);
  12. $metakeywords = get_field('wpprolister_seo_keyword', $post_id);
  13. $content = get_field('wpprolister_description', $post_id);
  14. $image = get_field('wpprolister_listing_slider_image', $post_id);
  15. $attachment_id = $image['ID'];
  16.  
  17. if (!empty($image)):
  18. $size = 'medium';
  19. $thumb = $image['sizes'][$size];
  20. if (defined('WPSEO_VERSION')) {
  21. update_post_meta($post_id, '_yoast_wpseo_title', $metatitle);
  22. update_post_meta($post_id, '_yoast_wpseo_metadesc', $metadesc);
  23. update_post_meta($post_id, '_yoast_wpseo_focuskw', $metakeywords);}
  24. //also update the content and featured image
  25. $my_post = array(
  26. 'ID' => $post_id,
  27. 'post_content' => $content,
  28. );
  29. wp_update_post($my_post);
  30. update_post_meta($post_id, '_thumbnail_id', $attachment_id);
  31.  
  32. endif;
  33.  
  34. }
  35. }
  36. }
Add Comment
Please, Sign In to add comment