wp_update_post breaks my function

Found the answer thanks to Jacobs comments + this similar thread: I had to use remove_action() WITH matching priority, like this: function booking_meta( $post_id, $post, $update ) { if ( get_post_type( $post_id ) !== ‘booking’ ) { return; } // Update ACF fields $object_id = get_the_ID(); $owner_id = get_the_author_meta( ‘ID’, $post->post_author ); update_field( ‘object’, $object_id, … Read more

wp_insert_post inserts 3 posts at once?

Thanks to @TomJNowell’s hint I managed to get it working with a simple check if the post already exists (using the post_exists function). This code is included in the functions.php file. Additionally, the loop only runs if called from the backend using the is_admin function. Here’s the working example: function ekesto_insert_post(){ // config $post_type=”event”; // … Read more

Overriding an existing filter

This is the pattern for a filter. Applying/using a filter on something: $filtered_version = apply_filters( ‘the name of the filter’, $the_thing_being_filtered ); This is how you use a filter to modify something: add_filter( ‘the name of the filter’, ‘name_of_a_function_that_will_modify_the_thing_being_filtered’ ); function name_of_a_function_that_will_modify_the_thing_being_filtered( $the_thing_being_filtered ) { // modify $the_thing_being_filtered here return $the_thing_being_filtered; } So in your … Read more

How to use: WP_AJAX_GET_COMMENTS

It is being used under wp-admin/js/post.js the function commentsBox.get. The purpose is to get Post comments. The UI related to it should be shown under the Comments page of WordPress. Though if you will further check the code, the selectors aren’t present there. So there’s no way you could use it just by calling out … Read more

Second featured image only shows in metabox preview after saving a post in the wordpress editor

The issue you’re experiencing, where the image preview in the meta box doesn’t update immediately when you change the second featured image, is likely due to the way the image preview is being handled in your jQuery code. To resolve this, you need to ensure that the image preview updates in real-time as soon as … Read more

Override categories with Pages (block theme)

In your scenario, where you want to override an auto-generated category page with a manually-created Page in WordPress, especially when using block themes, the challenge arises because block themes use a different file structure compared to classic themes. They rely on HTML templates and theme.json instead of the traditional PHP templates. Here’s a more elegant … Read more