Two problems that are likely related to AJAX

The problems turned out to have something to do with the sortable columns function I wrote before. Please see the function below. function cpt_date_orderby( $query ) { $orderby = $query->get( ‘orderby’ ); if( ‘date’ == $orderby ) { $query->set(‘meta_key’, ‘date’); $query->set(‘orderby’, ‘meta_value_num’); } } add_action( ‘pre_get_posts’, ‘cpt_date_orderby’ ); The problem lies in line 3 where … Read more

Ajax call undefined index

There are 2 problems: Problem 1 Your AJAX endpoint looks for my_id: $id = $_POST[‘my_id’]; But your javascript sends id: id : my_id Importantly: id != my_id They do not match. There is no $_POST[‘my_id’], that’s why you get a PHP notice Problem 2 You’re using $_POST but the code does not make a POST … Read more

ACF multi taxonomy on filterable gallery

Instead of getting all of the image IDs and then cycling through them and outputting each one, you would first collect them into a single array and then use array_unique() to remove the duplicates. if( $categories_du_projet ) : $image_array(); foreach( $categories_du_projet as $term ) : if( $image_du_projet ) : $image_array[] = $image_du_projet; endif; endforeach; $image_array … Read more

How to display acf field values from home page on all pages?

ACF’s the_field() and get_field() accept several parameters, one of which is a post ID. So, you just need to get the ID of the page the field is on, like this: <?php $frontpage_id = get_option( ‘page_on_front’ ); the_field(‘contact_form_title’, $frontpage_id); // For pages other than home $page = get_page_by_path(‘some-page-slug’); the_field(‘contact_form_title’, $page->ID); ?>