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

get post id in while loops outputting page id

Dont use query_posts or WP_Query if you need it in the main loop. Dont ever use query_posts anyway. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php $current_id = get_the_ID(); ?> <?php echo $current_id ?> <h1><?php the_field(‘titleFart’, $current_id); ?></h1> <?php endwhile; // end of the loop. ?> <?php endif; ?> … Read more

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