New answers tagged

0

Untested, but if I understand you correctly, try something like this: $results = new WP_Query( array ( 'post_id' => '<id-here>', 'post_type' => 'acf-field', //not necessary, but insurance 'post_excerpt' => '<custom-field-name>', //not necessary, but insurance 'meta_query' => array ( 'key' =>...


1

Your foreach doesnt have brackets or semicolons, probably thatÅ› why. and also not very well idented. Here it is the code properly idented, just one maybe, the foreach closing brackets probably must be after the return like in the code bellow, or maybe right before. if this code doesnt work cut and paste "return;" to right after the "endforeach;...


0

I don't see you querying for the posts that are using that category, Use get_posts like this: $first_posts = get_posts([ 'category_name' => 'first-post', // your category slug is ]); foreach( $first_posts as $p ) { wp_remove_object_terms( $p->ID, 'first-post' ); }


0

I found what was the problem. the code with actions were wrapped bu this following code : global pagenow; if ( $pagenow === "edit.php" && isset( $_GET['post_type'] ) ){} When there is an ajax call, $pagenow === admin-ajax.php and $_GET === [ ["_fs_blog_admin"]=> string(4) "true" ] so that could not be fired.


0

I noticed there was a 302 redirect in my network tab while saving. Save_post was being triggered twice, once from Inside my call, I simply included: $referrer = wp_get_referer(); if (strpos($referrer, 'http:') !== false) { error_log("not the right referrer, aborting"); return; } Issue solved.


Top 50 recent answers are included