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

PHP and Shortcode Combination

Concatenate the shortcode with the field value just before you evaluate it with do_shortcode. the_field(‘link’) will automatically output the value while get_field(‘link’) will return the value. <?php echo do_shortcode(‘[sociallocker]’. get_field(‘link’) . ‘[/sociallocker]’);?> The problem you had before is that your evaluating the first 1/3 which doesn’t include the data. Then you print the data. And … Read more

Get link picker custom field to show only if field exists

You’re testing if assigning a value to $mylink was successful in the if statement rather than testing if it’s empty. Try something like: <?php $article_link = get_field(‘article_link’); if( $article_link[‘url’] ): ?> <a href=”https://wordpress.stackexchange.com/questions/246505/<?php echo $article_link[“url’]; ?>”><?php echo $article_link[‘title’]; ?></a> <?php endif; ?> See Example 1 in the ACF docs.

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