ACF get Taxonomy Term meta — September 27, 2017

ACF get Taxonomy Term meta

ACF saves Taxonomy Term meta in wp_options table and here is how u can access it.

$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;

$value = get_field( 'test_field', $taxonomy.'_'.$term_id);
if( $value ) {
    echo $value;
} else {
    echo 'empty';
}
Advertisements
acf_form() after form submit handler — September 4, 2017

acf_form() after form submit handler

Here is one filter which can help you

add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
    //do whatever u want to do here
    //dont forget to return $post_id
    return $post_id;
}

For better information check this link.

Also need to make it more selective otherwise this will work for all acf_forms

add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
        print_r($GLOBALS['acf_form']);	
	$current_user = wp_get_current_user();
	$user_id = $current_user->ID;
	if($GLOBALS['acf_form']['post_id'] == 'user_'.$user_id)
	{
		$GLOBALS['acf_form']['return'] = site_url().'/owners-add-new-property/?step=started';
		update_user_meta($user_id, "current_profile_step", 4);
	}
	return $post_id;
}

You can see some unique info in ‘$GLOBALS[‘acf_form’]’ which will be unique for this post request. If still u have question add comment , will try to reply :).

WordPress check if user meta exists with same value for any other user except current user —
WordPress not able to use variables in get_template_part() — September 3, 2017
WordPress Use Environment Variables for diff domains like local, staging or production — August 15, 2017

WordPress Use Environment Variables for diff domains like local, staging or production

I always use this. Put this in wp-config.php

//GET HOSTNAME INFO
$hostname = $_SERVER['SERVER_NAME']; 

//VERIFY WHICH ENVIRONMENT THE APP IS RUNNING
switch ($hostname) {
    case 'site.dev':
        define('WP_ENV', 'local');
        break;
    case 'staging.site.com':
        define('WP_ENV', 'staging');
        break;
    case 'site.com':
        define('WP_ENV', 'production');
        break;
    default:
        define('WP_ENV', 'local');
}
WordPress filter for all images which appear in a page —
WordPress get posts where date is greater than particular date — July 26, 2017

WordPress get posts where date is greater than particular date

We need to use wordpress date_query for this query. Example:-

$the_query = new WP_Query(array(
	'post_type' => 'estate_property',
	'post_status' => 'publish',
	'posts_per_page' => 10,
	'order' => 'ASC',
	'date_query' => array(
	    array(
	        // 'after'     => 'June 22nd, 2017',
	        // 'before'    => 'December 31st, 2015',
	        'after'    => array(
				'year'  => 2017,
				'month' => 6,
				'day'   => 21,
			),
			'inclusive' => true,
	        
	    ),

	),
));

You can check wordpress documentation for better understanding.