ACF – Compare user and post data

There is a PHP function: preg_grep which accepts $pattern and $input as a parameters and returns you an array of matches. If you want to get first match just assign it to variable, e.x.: $field_os = array(‘windows-7′,’mac-os-10.07′,’linux-ubunto-16.04’); $user_os_type = “windows”; $matches = preg_grep(“https://wordpress.stackexchange.com/” . $user_os_type . “https://wordpress.stackexchange.com/”, $field_os); var_dump($matches); /* Prints: array(1) { [0]=> string(9) … Read more

Group/list/sort custom post type posts by date in tabs from acf datepicker field

It’s probably best to loop through your posts two times. Once to group them by year and once to print the posts. Something like this: (not tested) $formatted_posts = array(); while ( $subsQuery->have_posts() ) : $subsQuery->the_post(); $year = get_field(‘year’); // add them to formatted_posts array and group by year $formatted_posts[$year][] = $post; endwhile; foreach($formatted_posts as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)