Set default date in datepicker of an advanced custom field

It depends on the datepicker plugin you are using. Mostly all datepickers will have a default value you can play with. Usualy it is set within the input text type that hosts the datepicker. <input type=”text” class=”datepicker” default-value=”2013/07/25″> And in wordpress’ php you can do : <input type=”text” class=”datepicker” default-value=”<?php echo date(“Y/m/d”); ?>”>

Comparing arrays with meta_query in pre_get_posts

The ACF Documentation recommends checking the values individually rather than simultaneously using an array. The following code is from the ACF Documentation for the Checkbox field type: http://www.advancedcustomfields.com/resources/field-types/checkbox/ /* * Query posts for a checkbox value. * This method uses the meta_query LIKE to match the string “red” to the database value a:2:{i:0;s:3:”red”;i:1;s:4:”blue”;} (serialized array) … Read more

Gutenberg First Block on Page Conditional?

Here’s a solution I’ve come up with, that works with WordPress 5.4 and ACF Pro 5.8.9. First you need this function somewhere in functions.php: /** * Get ID of the first ACF block on the page */ function sg_get_first_block_id() { $post = get_post(); if(has_blocks($post->post_content)) { $blocks = parse_blocks($post->post_content); $first_block_attrs = $blocks[0][‘attrs’]; if(array_key_exists(‘id’, $first_block_attrs)) { return … Read more

Can not create fields in ACF with code

Action acf/init is available for pro version only, and I think you forgot to mention that you’re using the free version because with pro version above code worked fine. For basic version you have to use acf/register_fields to register your custom fields. So you need to modify your code to: function af_barbershop_address_field() { if ( … Read more

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