‘apply_filters’ is breaking some shortcodes/HTML but not all

try this: function reload_article_content() { check_ajax_referer( ‘reload_article_nonce’, ‘security’ ); $post_id = intval( $_POST[‘post_id’] ); // only run on posts where ‘is-live’ custom field is set to ‘true’ if ( get_post_meta( $post_id, ‘is-live’, true ) === ‘true’ ) { $post = get_post( $post_id ); if ( $post ) { $GLOBALS[‘post’] = $post; setup_postdata( $post ); ob_start(); … Read more

Filter hook for the action of listing users

Just like posts with WP_Query and pre_get_posts, there is WP_User_Query and pre_get_users that lets you modify the query parameters for fetching the users. This is the most efficient method of adjusting the list of users. e.g. add_action( ‘pre_get_users’, ‘justin_wylllie_pre_get_users’ ); function justin_wylllie_pre_get_users( \WP_User_Query $query ): void { // … modify the query object if we’re … Read more

How to add custom field to top of WordPress Comment Form for both logged in and anon users

I think you could use the comment_form_field_comment() filter to add the custom HTML before the main comment field. The filter is fired for both visitors and loggedin users. add_filter( ‘comment_form_field_comment’, ‘wpse_426971_comment_form_field_before’ ); function wpse_426971_comment_form_field_before( string $field ): string { return sprintf( ‘<p>%s</p>%s’, is_user_logged_in() ? “I’m logged in” : “I’m not logged in”, $field ); } … Read more

tech