Home Forums General Issues using the_field() in functions.php? Reply To: using the_field() in functions.php?

  • Hi @chanshaw

    Hmm… Please change the method query_posts() and use get_posts() instead and change your code to the following:

    function load_highest_order_number() {
    	$args = array(
    		'meta_key' 	=> 'order_number',
    		'cat'		=> 7);
    	$posts = get_posts($args);
    	foreach ($posts as $post):
    		echo get_field('order_number', $post->ID);
    	... // 

    Have a look at the documentation of get_posts() and query_posts() for more information on this. Here are the links: