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

Do something with thumbnail image on post publish

Actually WordPress offer a good hook , You can get data from Post Published , for more you can follow this example : https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post Example of a simple update of custom field: /* Do something with the data entered */ add_action( ‘save_post’, ‘myplugin_save_postdata’ ); /* When the post is saved, saves our custom data */ … Read more

How to add H1 Tag on Homepage?

For H1 Tag – “Top Shopping & Travel Deals”. Since you just want it static just adding <h1>Top Shopping & Travel Deals</h1> to a template is not hard. The likely hard part is determining which template is right place for it. You can consult with template hierarchy and check which templates theme has and which … 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