Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How can I get some of a posts meta data whilst it is still inserting?

Maybe you can move all the logic to added_post_meta & 'updated_postmeta' hooks.

add_action( 'added_post_meta', 'update_carnews_adverts_aprent', 10, 4 );
add_action( 'updated_postmeta', 'update_carnews_adverts_aprent', 10, 4 );

function( $meta_id, $object_id, $meta_key, $meta_value ) {
  if ( $meta_key !== '_wpcf_belongs_carnews_id' || ! is_numeric($meta_value) ) return;
  $post = get_post( $object_id );
  if ( $post instanceof WP_Post && $post->post_type == 'carnews-adverts' ) {
    $parent = get_post( $meta_value );
    if ($post->post_title !== $parent->post_title || $post->post_name !== $parent->post_name) {
       $post_update = array(
          'ID'         => $post->ID,
          'post_title' => $parent->post_title,
          'post_name' => $parent->post_name
       );
       wp_update_post( $post_update );
    }
  }
}

Related Posts:

  1. What hook should be used to programmatically create a post only when master post is updated?
  2. update_post_meta() whenever custom post type is updated
  3. Using preg_replace to filter custom textarea
  4. How to handle this specific case of custom post type?
  5. Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
  6. Create action running on trashed_post hook to modify post_meta value
  7. Add a post when another post type is inserting
  8. Update database from Quick Edit according to Checkbox state of Custom Post Type
  9. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  10. Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
  11. Dynamic Custom Fields
  12. Show Custom Post Type meta boxes only on Page Edit
  13. Custom filter function not working with Custom post type
  14. Filter Posts from the Main Query
  15. Post author for revision not being set on update/insert
  16. Add CPT values to Database
  17. Importing Data from a Non-WordPress database, into WP
  18. Getting thumbnails of a custom posts featured images in a page-templates metabox
  19. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  20. Remove Post Custom Meta Box
  21. Can’t publish custom post type – “You are not allowed to edit this post.”
  22. Custom fields for custom post type
  23. Show future events based on custom field AND order by date
  24. Why cant I add a custom post type to a custom taxonomy?
  25. Meta Data for Custom Post Type not saving
  26. Check if post with same meta value exists
  27. Filter date from post meta when date is in string format
  28. Create new custom post and post category of same name
  29. Get only used meta_values
  30. If Post Meta Equals Current Title Conditional Advanced Custom Fields
  31. Is there a way to exclude posts based on meta_values?
  32. Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
  33. Archieve.php not loading for custom post type
  34. wp_insert_post wrong post type [closed]
  35. Submitting Custom Post Types with custom fields from Front-end form
  36. Use remove_meta_box conditionally on custom post type
  37. create custom meta box with default value
  38. Programatically inserted posts not showing in Posts Table
  39. Get $post->ID from a URL
  40. Displaying a div from an assigned meta_value when on a page
  41. Meta data (Tags and Categories) for Custom Posts not showing.
  42. Display different information of a custom post type
  43. Include php on a specific page template
  44. Create Array from custom post type to display a slider
  45. Setting Post Title via Meta Data returns Auto-draft
  46. wp_trash_post action hook with custom post type
  47. How to Echo Metadata Value in Currency Format
  48. Issue on Working with Metabox – Checkbox to enable Sale Items
  49. Filter posts by tax (dropdown) and meta value
  50. How do I amend form data before it is saved for a custom post type
  51. delete_post_meta() for whole CPT / multiple posts?
  52. How to get specific post meta by title or id
  53. Publish and save specific postmeta to a filtered post_type
  54. What do the numbers mean at the end of add_action(‘save_post’)…?
  55. Is it possible to add posts and images (auto resize) for custom post types with a script?
  56. Running a wordpress action when a custom post type term (taxonomy category) is changed
  57. How to move a post to different post type with all meta data?
  58. Why do I have to press the “Update” button twice to save my meta box values?
  59. How can I display a drop-down select of Post Names
  60. how to show records that don’t have custom meta value
  61. WP API Response does not show my registered metadata
  62. How to detect that the save_post hook is calling the callback associated to the current edit post page only
  63. Update post if exist from PHP
  64. $post->post_meta not pulling any post in wordpress/php
  65. Values from meta-box not on $_POST
  66. WP_Query of custom post type sorted by meta_key has unexpected results
  67. Returning a custom content types with meta values
  68. WordPress hook which triggers on post import
  69. Custom post type suddenly stoped working after WordPress 5 update
  70. Batch Extract Date from post title and put into ACF custom field
  71. How to handle new post from API request?
  72. copy images from custom field to another custom field
  73. How to show custom field on specific custom post type posts only when filled
  74. Save CTP post meta different values each day without overwriting previous values
  75. get_post_meta returns NULL in front-end, but correct result in back-end
  76. Cannot obtain custom meta information
  77. Problem with adding custom post type meta to header by plugin
  78. is_main_query() never called on WP 4.4
  79. How can I output WPAlchemy repeating fields meta values in my page template?
  80. Meta box data is saved but NOT displayed in the meta box text field. Why?
  81. How to call a post’s metadata in shortcode.php?
  82. Types plugin custom post add_action hooks
  83. Save Metabox Custom Field Value
  84. Echo custom post meta from options array
  85. Value of post meta dropdown is not showing in WordPress
  86. Meta box data not saving
  87. Get all metadata for a given custom post type
  88. insert image with custom post type
  89. WP_Meta_Query object with conditionals
  90. Trying to write shortcode with get_post_meta but isn’t working
  91. Loading plugin text domain before registering post type
  92. importing table data to custom post type
  93. Related posts meta_query CPT
  94. Meta box with front-end styling
  95. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  96. add_action ‘init’ from inside a class for custom post types
  97. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  98. Advanced custom field – posted fields from custom post type
  99. Cannot Save MetaBox Data in Custom Post Type
  100. delete duplicate meta_value with same post_id
Categories custom-post-types Tags actions, custom-post-types, post-meta, wp-insert-post
Loading by Ajax a plugin that also uses Ajax
Why I obtain different visualization when I run the website on my local machine and on remote server?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress