Support

Account

Home Forums ACF PRO Homepage

Unread

Homepage

  • Hello,

    thanks to the help of the forum I was able to create a one page template using the relationship fields of ACF. The page works if displayed with exact address (www.mysite.com/homepage/), but if I set it as the homepage of the site I don’t see the values entered in the ACFs. This is the page code. Sorry for the dirty code, but I’m not a coder.
    Thanks in advance for help.

    <?php
    /*
    Template Name: Index-New
    */
    __( 'Index', 'mytheme' );// template name translation
    
    get_header(); ?>
    	<div>
    	<style type="text/css">
    						.titolocorr2 { width: 100%; text-align: center; border-bottom: 3px solid #F7E7C9; line-height: 0.1em; margin: 30px 0 15px; color: #5A302B; font-weight: bold; font-size: 26px;  } 
                            .titolocorr2 span {  background:#fff;  padding:0 10px; }
                            .flexcontainer { display: flex; flex-flow: row wrap; justify-content: flex-start; padding: 0; margin: 0; width: 100%;}
                            .flexcontainer1 { display: flex; flex-flow: row wrap; justify-content: flex-start; padding: 0; margin: 0; width: 100%;}
    						.flexitem { padding: 5px; margin-top: 10px; flex: 30%; }
    						.item { padding: 5px; margin-top: 10px; flex: 45%;  }
    						.item:nth-child(2n) { flex: 45%; }
    						.item:nth-child(3n) { flex: 30%; }
    						.item:nth-child(4n) { flex: 30%; }
    						.item:nth-child(5n) { flex: 30%; }
    						.flexitem:nth-child(2n) { flex: 30%; }
    						.flexitem:nth-child(3n) { flex: 30%; }
    						.flexitem:nth-child(4n) { flex: 30%; }
    						.flexitem:nth-child(5n) { flex: 30%; }
    						@media (max-width: 500px) {  
      						.ricettatitle { font-size: 20px; }
      						.item { flex: 100%;  }
      						.item:nth-child(2n) { flex: 30%;  }
      						.item:nth-child(2n) span { display: none;  }
      						.item:nth-child(3n) span { display: none;  }
      						.item:nth-child(4n) span { display: none;  }
      						.flexitem { flex: 100%; }
      						}
      						@media (min-width: 501px) { 
      						.ricettatitle { font-size: 24px; }  
      						}
      			
    	</style>
    	
    	
    		<?php
                             
                            // check if the repeater field has rows of data
                            if( have_rows('blocchi_homepage') ):
                                
                                // loop through the rows of data
                                while ( have_rows('blocchi_homepage') ) : the_row();
                            ?> 
    
                            <?php 
                            $titolo = get_sub_field('titolo'); 
                            $locations = get_sub_field('articolo');
                            $descrizione = get_sub_field('descrizione');
                            
                            if( $locations ): ?>
                            
    						
    						<p class="titolocorr2"><span><?php echo $titolo ?></span>
    
    						<div class="flexcontainer">
    						<?php foreach( $locations as $location ): ?>
    						<?php 
    						$imgcorr2 = get_the_post_thumbnail_url($location->ID,'size_600_400');
    						$permalinkcorr2 = get_permalink( $location->ID );
    						$titlecorr2 = get_the_title( $location->ID );
    						$excpertcorr2 = get_the_excerpt($location->ID );
    						 ?>
    						<div class="flexitem" style="box-shadow: 0 2px 10px rgba(0,0,0,.07); ">
    						 
    						 <?php if ( $imgcorr2 ) : ?>
    									<img src="<?php echo $imgcorr2; ?>" alt="<?php echo $titlecorr2; ?>" height="auto" width="100%"/>
    						 <?php endif; // If has image ?>
    						 
    						<a href="<?php echo $permalinkcorr2  ?>" rel="bookmark" title="<?php echo $titlecorr2; ?>" class="ricettatitle"><?php echo $titlecorr2 ?></a>
    						 <?php if ($descrizione) :  ?>
    						 <br>
    						 <span><?php echo short( $excpertcorr2, 70 ); ?></span>
    						  <?php endif;  ?>
    						 
    						 </div>		
    						 
    					   
                            <?php endforeach; ?>
                            </div>
    						
                            
                            <?php endif;?>
                                
    						
    
                            <?php 
                                endwhile;
                             
                            else :
                             
                                // no rows found
                             
                            endif;
                             
                            ?>
    
    </div><!-- .content -->
    
    </div>
    </div>
    <?php get_footer(); ?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.