Support

Account

Home Forums General Issues Output of all checkboxes with specific class for checked objects

Helping

Output of all checkboxes with specific class for checked objects

  • hey guys, i’m new at acf and totally satisfied of this amazing wordpress plugin. but now i’ve my first issue.

    for a custom post type i created a custom-field with all months of the year as checkboxes. i already managed the output of all values, not just the checked ones.

    <?php $field_key = “field_537b44c38dd36″; $field = get_field_object($field_key); if( $field ) { echo ‘<p class=”‘ . $field[‘key’] . ‘”>’; foreach( $field[‘choices’] as $k => $v ) { echo ‘‘ . $v . ‘‘; } echo ‘</p>’; }
    ?>

    in frontend i get this:

    <p class=”field_537b44c38dd36″>
    Jan
    Feb
    Mar
    Apr
    Mai
    Jun
    Jul
    Aug
    Sep
    Okt
    Nov
    Dez
    </p>

    that’s all fine, but now i want to give the checked ones specific classes like “checked”. at the end it should look like this:

    <p class=”field_537b44c38dd36″>
    Jan
    Feb
    Mar
    Apr
    Mai
    Jun
    Jul
    Aug
    Sep
    Okt
    Nov
    Dez
    </p>

    is that possible. would be nice to get some help.
    cheers.

  • sh*t, html was transformed.

    this:

    <p class="field_537b44c38dd36">
    <a value="Jan">Jan</a>
    <a value="Feb">Feb</a>
    <a value="Mar">Mar</a>
    <a value="Apr">Apr</a>
    <a value="Mai">Mai</a>
    <a value="Jun">Jun</a>
    <a value="Jul">Jul</a>
    <a value="Aug">Aug</a>
    <a value="Sep">Sep</a>
    <a value="Okt">Okt</a>
    <a value="Nov">Nov</a>
    <a value="Dez">Dez</a>
    </p>

    should be something like this:
    this:

    <p class="field_537b44c38dd36">
    <a value="Jan">Jan</a>
    <a value="Feb">Feb</a>
    <a value="Mar">Mar</a>
    <a class="checked" value="Apr">Apr</a>
    <a class="checked" value="Mai">Mai</a>
    <a value="Jun">Jun</a>
    <a class="checked" value="Jul">Jul</a>
    <a value="Aug">Aug</a>
    <a value="Sep">Sep</a>
    <a class="checked" value="Okt">Okt</a>
    <a value="Nov">Nov</a>
    <a value="Dez">Dez</a>
    </p>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Output of all checkboxes with specific class for checked objects’ is closed to new replies.