Home › Forums › Backend Issues (wp-admin) › Sorting a column for a user field › Reply To: Sorting a column for a user field
Another bit of code to go with the previous one that updates all previously created posts of type my_custom_post_type with the extra meta data instead of having to manually do it.
/**
* Update post meta for sortable column
*/
if (is_admin() && isset($_GET['addsortablemeta']) && $_GET['addsortablemeta'] == 1) {
$args = array(
'post_type' => 'my_custom_post_type',
'nopaging' => true,
);
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
while ($my_query->have_posts()) : $my_query->the_post();
my_acf_save_post($post->ID);
endwhile;
}
wp_reset_query();
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.