ACF not showing

the_field() function shows the value and it doesn’t get/return anything. Like the_title() and other template tags starting with the_. It means that: This line prints the value and $hero variable is empty. $hero = the_field(‘hero_title’); This line prints only <h1> tags. echo ‘<h1>’.$hero.'</h1>’; What you want is: echo ‘<h1>’ . get_field(‘hero_title’) . ‘</h1>’;

Image Shortcode from ACF ID

It’s because you have forgot to use $atts[‘post_id’] please find below code. function acf_featured_item_shortcode( $atts ) { // Attributes $atts = shortcode_atts( array( ‘post_id’ => ”, ), $atts ); $post_id = $atts[‘post_id’]; $image = get_field(‘featured_item’, $post_id ); $size=”medium”; // (thumbnail, medium, large, full or custom size) if( $image ) { $output = wp_get_attachment_image( $image, $size, … Read more

Is there a better way to pull in custom content without querying posts?

It’s not a hack, this is what databases are designed for- querying large quantities of data. If you’re concerned about load, you should employ caching on data that doesn’t change frequently. That said, you should not be using query_posts to create additional queries. Really, you shouldn’t be using query_posts at all. Create additional queries via … Read more

ACF Add fields values to newly inserted post [closed]

You can do this instead of using update_field(): update_post_meta($post_id, ‘fieldname’, $value); update_post_meta($post_id, ‘_fieldname’, ‘field_’ . uniqid()); // `uniqid() is a native PHP function. This is also how ACF creates the field keys Also, depending where you are retrieving the value, you may also have to pass the post id. the_field(‘fieldname’, $post_id);

Redirect to another page using contact form 7? [closed]

Redirect to another page using contact form 7? [closed]

ACF: post query, hide duplicate values [closed]

You could pass all the fields into an array during your while loop, strip the array of duplicates, and then run a foreach loop on that array. It would look something like this: <?php $designers = array(); while ( $the_query->have_posts() ) : $the_query->the_post(); $designers[] = get_field(‘products_page_designer_name’); endwhile; // This will strip out any values that … Read more

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