• Hi,

    Created a custom posttype to get my projects. I want to select the projects which will be displayed on the homepage, so I created a Advanced Custom Field True/False. The default value is set to true, so every project will be shown.

    Now when I browse to the site, I only see the boolean returned for the first project, the other ones return NULL.
    Therefore I think I have to do something with a foreach loop, but don’t know how to accomplish this. Any help is appreciated…

    My code so far…
    `<?php
    /*
    * Template Name: Homepage
    */
    get_header(); ?>

    <?php
    $projects = array(‘post_type’ => ‘project’, );
    $loop = new WP_Query($projects);
    while($loop->have_posts()) : $loop->the_post();
    $truefalse = get_field(‘show_on_homepage’);
    ?>

    <?php
    the_title();
    echo ‘

    ';
    var_dump($truefalse);
    echo '

    ‘;
    ?>

    <?php endwhile; ?>

    <?php get_footer(); ?>

Viewing 1 replies (of 1 total)
  • Thread Starter floi13

    (@floi13)

    After some tinkering about, it looks like it has to do something with the default value.
    When I uncheck all projects (set to false) and check only one project (set one to true), I get 3 times a ‘boolean:false’ back and one ‘boolean:true’.

    Seems correct so far…

    But what if I want to use the default ‘true’ value?

Viewing 1 replies (of 1 total)

The topic ‘ACF true/false’ is closed to new replies.