Count custom post types with a specific meta value

1st. you need to add post_type to your query, then you need to filter meta_value with LIKE. Finaly, you need to add posts_per_page as -1 to get ALL posts. $args = array( ‘post_type’=> ‘books’, ‘meta_query’ => array( array( ‘key’ => ‘book_type’, ‘value’ => ‘Fiction’, ‘compare’ => ‘LIKE’, ) ), ); $query = new WP_Query($args); $fiction … Read more

Advanced custom field – gallery – display one random image

Shouldn’t you be doing something like this? <img src=”https://wordpress.stackexchange.com/questions/99655/<?php echo $rand[“url’]; ?>” alt=”https://wordpress.stackexchange.com/questions/99655/<?php echo $rand[“alt’]; ?>” /> Update I’m not really familiar with that plugin (stuff could be happening behind the scenes) but here’s a better guess than my previous one: <?php $gallery = get_field(‘gallery_home’); $rand = array_rand($gallery, 1); if( $gallery ): ?> <img src=”https://wordpress.stackexchange.com/questions/99655/<?php … Read more

Get the label from ACF checkbox [closed]

You can try this $field = get_field_object(‘color’); $colors = get_field(‘color’); // array of selected color values foreach($colors as $color){ echo “selected color: “. $color. ” with label: ” . $field[‘choices’][ $color ]; } where the labels are fetched by get_field_object according to the link you provided. You could also use print_r() or var_dump() to check … Read more

Retrieve a specific field from taxonomy term through advanced custom fields [closed]

To retrieve a field from ACF for a term (instead of, for example, a post), you should use the taxonomy name, followed by an underscore, followed by the term ID instead of the post ID when calling the_field or get_field. Assuming you want to retrieve the field image_toc for the taxonomy mytax and term ID … Read more

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