If/Else Statement for Advanced Custom Fields

<?php if( get_field(‘parent_repeater’) ) : while( has_sub_field(‘parent_repeater’) ) : $some_bool = get_sub_field(‘true’); $sf1 = get_sub_field(‘sub_field_1’); $sf2 = get_sub_field(‘sub_field_2’); if( $some_bool == true ){ echo $sf1 . $sf2; } else { echo $sf1; } endwhile; endif; ?> You must use the non-echoing version of the function. Use the get version. Also, I advise you to use … Read more

Basic do shortcodes question

the_field() is an ACF function and will echo content. It follows the WordPress (somewhat) pattern whereby functions with the_ at the front will echo content and functions beginning with get_ return content. Displays the value of the specified field. (this is the same as “echo get_field($field_name)”) http://www.advancedcustomfields.com/resources/functions/the_field/ Using the wrong function, as you have, will … Read more

filter wp_query result with custom field values

If main_category is a category (custom taxonomy), then you’re querying it wrong. This should go like this: $electronics = array( ‘numberposts’ => -1, ‘post_type’ => ‘article’, ‘main_category’ => ‘electronics’ ); $query_electronics = new WP_Query( $electronics ); If that’s a custom field, use meta_query: $electronics = array( ‘numberposts’ => -1, ‘post_type’ => ‘article’, ‘meta_query’ => array( … Read more

Slashes stripped in ACF

Until this gets fixed, the only workaround I can see is to intercept the $_POST data and add extra slashes prior to ACF stripping them: /** * @link http://wordpress.stackexchange.com/q/143555/1685 */ function wpse_143555_acf_add_slashes() { if ( ! empty( $_POST[‘fields’] ) ) { foreach ( $_POST[‘fields’] as $k => $v ) { if ( ! is_array( $v … Read more

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