Support

Account

Forum Replies Created

  • I realised that i was missing an s in get_field – so it works with get_fields (array)

  • Thank you so much!

    I made it work with just getting them from $cases array.

    
     <?php
                            $cases = get_field('forside_cases');
                            
                            if( $cases ): ?>
    
                                <div class="cases-section">
                                    <h2><?php echo $cases['cases_overskrift']; ?></h2> 
                                    <div class="container">
                                        <div class="case-text col col--xs-12 col--sm-12 col--md-6 col--lg-6">
                                            <p class="title"><?php echo $cases['case_virksomhedsnavn']; ?></p>
                                            <p class="text"><?php echo $cases['case_tekst']; ?></p>
                                            
                                            <?php 
    
                                            $active_services = $cases['aktive_ydelser'];
    
                                            if( $active_services ): 
                                            ?>
                                            <p>Samarbejdet indeholder bla.</p>
                                            <ul>
                                                <?php foreach ( $active_services as $active_service): ?>
                                                <li class="active-service"><?php echo $active_service; ?></li>
                                                <?php endforeach; ?>
                                            </ul>
                                            <?php endif; ?>
    
                                            <a href="#" title="Se cases" class="cta">Send mig et forslag på et samarbejde <i class="fa-solid fa-arrow-right-long"></i></a>
    
                                        </div>
                                        <div class="case-image col col--xs-12 col--sm-12 col--md-6 col--lg-6">
                                            <img src="<?php echo $cases['case_billede_url']; ?>" alt="<?php echo $cases['case_virksomhedsnavn']; ?>">
                                        </div>
                                    </div>
                                </div>
    
                            <?php endif; ?>
    
  • The checkbox field is inside a group.
    Field Group => Field type: Group => Field Type: Checkbox

    Is it that?

  • I only have that one loop, and then other fields like text and link

    I don’t know if you can see much out of it – there are php between the Danish mumbojumbo language but here is the whole page code:

    
    <?php
    
        /**
         * Template Name: Forside
         */
    
        get_header();
    
    ?>
    <main class="main" role="main">
        <div class="container">
    
            <?php while ( have_posts() ) : the_post(); ?>
    
                        <div class="content">
                            <?php the_content(); ?>
    
                            <?php 
                            $hero_cta = get_field('forside_hero_cta'); 
                            if ($hero_cta) :
                            ?>
                            <div class="focus_cta">
                                <a href="<?php echo $hero_cta['url']; ?>" title="<?php echo $hero_cta['title']; ?>" class="cta"><?php echo $hero_cta['title']; ?> <i class="fa-solid fa-briefcase-medical"></i></a>
                            </div>
                            <?php endif; ?>
    
                            <?php
                            $services = get_field('forside_ydelser');
                            if( $services ): ?>
                                <div class="services-section">    
                                    <h2><?php echo $services['ydelse_overskrift']; ?></h2> 
                                    <div class="services">
                                        <a href="<?php echo $services['cta_link_1']['url']; ?>" title="<?php echo $services['cta_link_1']['title']; ?>" class="service"> 
                                            <h3><?php echo $services['ydelse_1_overskrift']; ?> <i class="fa-solid fa-circle-nodes"></i></h3>
                                            <?php echo $services['ydelse_1_tekst']; ?>
                                            <span class="readmore"><?php echo $services['cta_link_1']['title']; ?> <i class="fa-solid fa-arrow-right-long"></i></span>
                                        </a>
    
                                        <a href="<?php echo $services['cta_link_2']['url']; ?>" title="<?php echo $services['cta_link_2']['title']; ?>" class="service">
                                            <h3><?php echo $services['ydelse_2_overskrift']; ?> <i class="fa-solid fa-gears"></i></h3>
                                            <?php echo $services['ydelse_2_tekst']; ?>
                                            <span class="readmore"><?php echo $services['cta_link_2']['title']; ?> <i class="fa-solid fa-arrow-right-long"></i></span>
                                        </a>
                                    
                                        <a href="<?php echo $services['cta_link_3']['url']; ?>" title="<?php echo $services['cta_link_3']['title']; ?>" class="service">
                                            <h3><?php echo $services['ydelse_3_overskrift']; ?> <i class="fa-solid fa-hashtag"></i></h3>
                                            <?php echo $services['ydelse_3_tekst']; ?>
                                            <span class="readmore"><?php echo $services['cta_link_3']['title']; ?> <i class="fa-solid fa-arrow-right-long"></i></span>
                                        </a>
    
                                        <a href="<?php echo $services['cta_link_4']['url']; ?>" title="<?php echo $services['cta_link_4']['title']; ?>" class="service">
                                            <h3><?php echo $services['ydelse_4_overskrift']; ?> <i class="fa-solid fa-arrow-trend-up"></i></h3>
                                            <?php echo $services['ydelse_4_tekst']; ?>
                                            <span class="readmore"><?php echo $services['cta_link_4']['title']; ?> <i class="fa-solid fa-arrow-right-long"></i></span>
                                        </a>
                                    </div>
                                    <div class="focus_cta">
                                        <a href="#" title="Få tilsendt et overblik over alle ydelserne" class="cta">Få tilsendt et overblik over alle ydelserne <i class="fa-solid fa-arrow-right-long"></i></a>
                                    </div>
                                </div>
                            <?php endif; ?>
    
                            <?php
                            $cases = get_field('forside_cases');
                            
                            if( $cases ): ?>
    
                                <div class="cases-section">
                                    <h2><?php echo $cases['cases_overskrift']; ?></h2> 
                                    <div class="container">
                                        <div class="case-text col col--xs-12 col--sm-12 col--md-6 col--lg-6">
                                            <p class="title"><?php echo $cases['case_virksomhedsnavn']; ?></p>
                                            <p class="text"><?php echo $cases['case_tekst']; ?></p>
                                            
                                            <?php 
                                            $active_services = get_field("aktive_ydelser");
    
                                            //var_dump($active_services);
    
                                            if( $active_services ): 
                                            ?>
                                            <p>Samarbejdet indeholder bla.</p>
                                            <ul>
                                                <?php foreach ( $active_services as $active_service): ?>
                                                <li class="active-service"><?php echo $active_service; ?></li>
                                                <?php endforeach; ?>
                                            </ul>
                                            <?php endif; ?>
    
                                            <a href="#" title="Se cases" class="cta">Send mig et forslag på et samarbejde <i class="fa-solid fa-arrow-right-long"></i></a>
    
                                        </div>
                                        <div class="case-image col col--xs-12 col--sm-12 col--md-6 col--lg-6">
                                            <img src="<?php echo $cases['case_billede_url']; ?>" alt="<?php echo $cases['case_virksomhedsnavn']; ?>">
                                        </div>
                                    </div>
                                </div>
    
                            <?php endif; ?>
                            
                        </div>
    
            <?php endwhile; ?>
    
        </div>
    </main>
    
    <?php get_footer(); ?>
    
  • The frontpage setting is set to a static page .

  • And i have other fields next to this section that works. Sorry for the multiple answers (i will try to keep it to one next time)

  • And if neccerary – This page is my frontpage.

  • Hi John

    Its a standard page with a custom page template.

    Its inside a post loop so i can start the page with text from the editor, and then fill in the ACF fields to add items to the sections on the page like the previous example.

    
    <?php
    while ( have_posts() ) : the_post();
    
    $active_services = get_field("aktive_ydelser");
    
    //var_dump($active_services);
    
    if( $active_services ): 
    ?>
    <p>Samarbejdet indeholder bla.</p>
    <ul>
    <?php foreach ( $active_services as $active_service): ?>
    <li class="active-service"><?php echo $active_service; ?></li>
    <?php endforeach; ?>
    </ul>
    <?php endif; 
    endwhile;
    ?>
    

    Is that enough context or?

Viewing 8 posts - 1 through 8 (of 8 total)