Ajax not working properly

Just saw it… …in your HTML, take the action out entirely. We’re not using the HTML to tell the form/submit button what to do, we’re using JS/AJAX for that. <form method=”POST” action=”<?php echo admin_url(‘admin-ajax.php’); ?>” id=”modal-form-ajax” autocomplete=”off”> Should become: <form method=”POST” id=”modal-form-ajax” autocomplete=”off”> Also, instead of targeting the form, target the submit button, so the … Read more

Automatically wrap multiple images in div

This is a function I use to add a wrapper to each image. I know it’s not 100% what you want, but I thought this might give you a handle to work from. function add_image_wrapper( $content ) { $content = preg_replace_callback( ‘/<img[^>]+>/im’, function ( $matches ) { $image = $matches[0]; $classes = array(); preg_match( ‘/class=”align([^”]+)”/im’, … Read more

Get the link for RSS item to display in feed

The the_permalink_rss() is echoing it’s content not returning it. If we look at the source of this function: https://developer.wordpress.org/reference/functions/the_permalink_rss/ We can just copy what it’s doing, as it’s a simple function. $link = esc_url( apply_filters( ‘the_permalink_rss’, get_permalink() ) );

Unset Category if other Category is unset during post transition

You can use the deleted_term_relationships action to check if some term is removed from a post object. This hook is in the wp_remove_object_terms() function custom_remove_category( $object_id, $tt_ids, $taxonomy ) { if( $taxonomy == ‘category’ ) { if( in_array( 3152, $tt_ids ) ) { wp_remove_object_terms( $object_id, [1208], ‘category’ ); } } return $object_id; } add_action( ‘deleted_term_relationships’, … Read more