Support

Account

Home Forums General Issues How to call ACF fields from my functions.php file Reply To: How to call ACF fields from my functions.php file

  • My code has several levels. This code I sent you before is the code for projects-image.php (see get get_template_part below) and the loop for my posts is inside projects.php, from where I am calling different files with different ACF structure, like this:

    <?php get_header(); ?>
    
    <?php
    /*
    Template Name: Projects
    */
    ?>
    
    <?php $query = new WP_Query( 
    	array( 
    		'posts_per_page' => 1, 
    		'category_name' => 'projects',
    		'orderby' => 'date',
    		'order'      => 'DESC'
    		));
    
    if ( $query->have_posts() ) {
    	while ( $query->have_posts() ) {
    		$query->the_post();?>
    
    				<div class="row">
    					<article class="projects large-12 columns ">
    						<section class="large-6 large-centered columns">
    
    							<?php if( have_rows('projects_content') ):
    							while ( have_rows('projects_content') ) : the_row(); ?>
    
    							<?php get_template_part( 'project', 'image' ); ?>
    							<?php get_template_part( 'project', 'video' ); ?>
    							<?php get_template_part( 'project', 'text' ); ?>
    
    						<?php endwhile;?>
    					<?php endif; ?>
    				</section>
    			</article>
    		</div><!-- end.row -->
    
    	<?php // Copyright ?>
    	<div class="row">
    		<?php get_template_part('/parts/copyright'); ?>
    	</div>
    
    	<?php }
    } else {
    	// no posts found
    }
    // Restore original Post Data
    wp_reset_postdata();?>
    
    <?php get_footer(); ?>