How to update an image attachment’s alt text from a custom field when saving a post?

I found the problem. It was updating the post instead of the attachment. So instead of $post->ID, I create another string that stores the image ID and replace that with post->ID and it works. function post_extra_save( $post_id, $post){ if ( has_blocks( $post->post_content ) ) { $blocks = parse_blocks( $post->post_content ); foreach ( $blocks as $block … Read more

WordPress – display relationship between blog posts and custom posts

Below is the updated code to fetch posts, please check is that helpful: $documents = get_posts(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘our_people_author’, // name of custom field ‘value’ => ‘”‘ . get_the_ID() . ‘”‘, // matches exaclty “123”, not just 123. This prevents a match for “1234” ‘compare’ … Read more

Filter result of Custom Post Type using meta_query with ACF

For meta_query with ACF and ordering price by ASC or DESC try following code. $args = array( ‘post_type’ => ‘property’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘price’, ‘orderby’ => ‘meta_value_num’, ‘order’ => $_GET[‘orderby’], ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘contract’, ‘value’ => $_GET[‘contract’], ), array( ‘key’ => ‘rooms’, ‘value’ => $_GET[‘rooms’], ), … … Read more