Support

Account

Forum Replies Created

  • In case it is option page

    <script>
    var testVar = "<?=get_field('field_name','option'); ?>";
    </script>

    In case it is CPT:

    <script>
    var testVar = "<?=get_field('field_name',$post_id); ?>";
    </script>

    So, now you can use testVar in your jQuery after loading page

    Trick:
    store php & MySql value in hidden inputs with known id and then get this input value by its id in your jQUery code

  • Replace ‘paged’ => $paged by ‘posts_per_page’ => -1,

    
    	$args = array(
    		'post_type' => 'recipes',
    		'post_status' => 'publish',
    		'posts_per_page' => -1,
    		'meta_query' => array(
    			array(
    				'key' => 'cookies_products_used',
    				'value' => $ptype,
    				'compare' => 'LIKE'
    			)
    		)
    	);
    
    // start get values you want
    	$the_query = new WP_Query($args);
    	if ($the_query->have_posts()) {
    		while ($the_query->have_posts()) {
    			$the_query->the_post();
    			
    			// for example
    			$cookies_products_used = get_field('cookies_products_used',get_the_ID());
    		}
    	}
Viewing 2 posts - 1 through 2 (of 2 total)