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

save-post

How do I set a custom post type Category after import using wp_set_post_terms

The answer is don’t use wp_set_post_terms, use wp_set_object_terms instead. wp_set_post_terms only works with the built-in post object.

Categories hooks Tags actions, hooks, save-post, the-events-calendar

Get category of post inside save_post hook

Your code calls get_the_category() but it doesn’t use the value returned. // … if ( isset( $_POST[‘img-destacada’] ) ) { $categories = get_the_category($post_id); $img = ”; // $categories should contain either an array of WP_Term objects, // or an empty array. if ( ! empty( $categories ) ) { // Here I’ve used the slug … Read more

Categories functions Tags categories, functions, hooks, save-post

How to use wp_set_object_terms depending on page ID?

How to use wp_set_object_terms depending on page ID?

Categories custom-post-types Tags custom-post-types, custom-taxonomy, functions, save-post, terms

Use save_post to generate file on wordpress

Use save_post to generate file on wordpress

Categories save-post Tags save-post

if condition from post_meta not working in save_post

if condition from post_meta not working in save_post

Categories post-meta Tags post-meta, save-post

acf/save_post affecting WP_Query results

acf/save_post affecting WP_Query results

Categories meta-query Tags meta-query, save-post

UI does not show correct Slug after modified using save_post action

Through trial and error I was able to get this working reliably without further hooks or using JavaScript in the Editor. After restoring the hook, I added clean_post_cache($post_id); Separately, I updated the order of priority (from 10 to 5) for the original action. The code in the original question has been updated to reflect this.

Categories permalinks Tags admin-ui, permalinks, save-post, slug

Taxonomy Child Not Updating Unless I Click Update Twice

Taxonomy Child Not Updating Unless I Click Update Twice

Categories custom-taxonomy Tags custom-taxonomy, save-post, terms, wp-update-post

get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post

get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post

Categories post-meta Tags post-meta, save-post

Save frontend submission form field as custom field

I you need to use update_post_meta($post_id,’your_meta_key’,’your_meta_value’); or you can save in new variable like $city_value = $_POST[‘city_field’]; then code will be update_post_meta($post_id,’city_field’,$city_value);

Categories post-meta Tags post-meta, save-post
Older posts
Newer posts
← Previous Page1 Page2 Page3 Page4 … Page40 Next →
+ More

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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
Next Page »
  • 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