I found an answer.
Essentially I had an infinite loop that was quite puzzling at first. It made more sense as I saw that it never iterated beyond the first item in the post array.
I found the answer here:
https://tommcfarlin.com/update-post-in-save-post-action/
The issue is that wp_update_post hooks into save_post… so every time I would reach that, it would restart again. To fix this, I changed my code to read:
function officers_onto_board_page_save( $post_id ) {
remove_action( 'save_post', 'officers_onto_board_page_save' );
//DO STUFF
add_action( 'save_post', 'officers_onto_board_page_save');
}
By removing the function and then re-adding it to save_post
, it operates as expected.
Related Posts:
- Inserting data into `post meta` table?
- foreach loop inside the loop creating duplicates in output
- See if the email exists or not
- Inconsistent temporary 404s on whole install | PHP error with post-template.php
- Query menu_order custom post types
- Search that will look in custom field, post title and post content
- Load custom posts with same tag as page
- using the_permalink to echo an href into a
- Date archives for custom post type
- If featured image doesn’t exist, show post content
- How can I add dropdown widget/box to admin post page?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- How do I redirect all 404 errors of a specific post type to another URL?
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Get custom post type REST API not working
- How to save the checked boxes?
- How to get only one category of custom post type?
- Error after deleting Custom Post Type with a function (no trash used)
- Get all taxonomies for all post types
- Append taxonomy terms as class names in markup?
- Change message given when deleting post from custom post type
- wordpress custom post type remove duplicate menu item
- Using WPAlchemy metabox values in another metabox
- Display custom field of specific post where post title matches variable
- GravityForm: Populate Dropdown with custom post type [closed]
- How to output wordpress custom tags separated by comma?
- Show Different Header on a Specific Post ID
- Admin notice not displaying
- Dynamic page outside WordPress
- Custom query to filter posts that have current post as a taxonomy [closed]
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- Custom Post Type Loop throws 500 error when used in widget
- Received nothing after executing AJAX post function
- If post has custom field then display css-class
- Replace text in post from cvs
- convert custom query to wp_query
- Custom Tag Description unable to display just below and outside of the Loop
- I need to add endpoint for wordpress categories
- Can one create multiple Custom Post Types with a for loop?
- Categorize custom post type
- Hide a widget inside a div on specific type of post
- How to import a custom MySQL DB table into a WordPress custom post type
- Breaking up CPT output into two columns
- Function causing the loop display posting more (empty)
- Foreach inside shortcode not working as planned
- Post author for revision not being set on update/insert
- Displaying custom field according to date
- Add additional field to custom post_type
- $post not working working in AJAX plugin with custom post type
- Set featured image to archive.php
- Get term name without a foreach loop
- Add first letter of titles to array, then compare arrays
- custom post for slider
- Using wp_query to modify the loop in index.php for a CPT
- Get custom post type categories to show up in menus
- How exclude or skip post type with get_next_post_link
- widget_posts_args not using the number of posts in widget
- Create short URL with auto 301 redirect
- Is it possible to use array_walk() to append terms to an array of posts?
- get_post_types() can’t get some of my post type
- Creating shortcode id for custom post types
- Different column width in 2 rows with bootstrap and custom post types-different classes needed
- Menu’s breaking, now showing all page links on site
- Page that lists publications by classifying them by taxonomy
- count & sum the value of custom field of the author post in dynamic posts
- Title and URL Error in Breadcrumb Navigation for Custom Post Types
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- Assigning categories to custom post types via a front-end form; only works for native post type
- How to limit the number of custom posts certain users can publish in WordPress using php script?
- Custom sorting in post columns by ACF Pro Select Field
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- programmatically generated custom post type is created more than once
- Visualize info in just custom post_type in theme
- cpt not display inside nav menu
- wp_post_delete is deleting all offices
- Accessing download link from the loop with WP Download Manager Pro
- Custom Post Type has wrong label and is not found when called by a loop
- Create posts inside CPT post
- current-post-parent for custom post type
- Having issue on Loading Meta Data From CSV to CPT
- Rewrite URL of Specific Post of Custom Type
- update flamingo_inbound post type after insert
- Print post category name from a custom post type wordpress
- Update 2 wordpress tables at once
- The most recent post of custom taxonomy
- How to make sure, that only the selected post is changing?
- Meta Box not being added in plugin
- Why isn’t my custom post type using the corresponding custom post template?
- Get month and day from a Date Picker custom field
- Shared Custom post type between WP network sites
- Change custom post status to draft before today
- Show Custom Post Type taxonomy term that matches custom field
- Query Distinct Taxonomies of Custom Post Type
- Order by custom field attribute
- Select Menu for Custom post Type does not save
- Saving custom metabox data with a twist
- is_singular won’t call my functions?
- Code in custom widget queries all posts, when it should only query the current post
- Inserting two categories
- Comments are not working on Custom Post Type