Support

Account

Forum Replies Created

  • @trint33 Fantastic! there’s always different ways to do things I guess.
    Glad I could help, take care,
    Dave

  • You could always make a repeater field that will generate the css classes and then use the load-field function to put those class names in the select dropdown values, that because the classes names and colours will always come from the Options page direct into the css you wouldn’t have to worry about then reloading the child pages when you update the content.

    good luck!

  • Ah, so I know how I got mine “working”
    my web to print system uses ACF form to display the content on the front end of the website (allowing people to move the content around using flexible content).

    To make sure the new content is loaded in I added a jquery script that presses the update button when the page is done loading, so it loads twice (bringing in the new content).

    So actually, my way wouldn’t work for you.

    Your value is saved in the database when choose it on the very last page in wordpress before the front end correct?

    You could always change the colour by using classes instead in css.

    so have 5 classes that you change the colour of in your header.php for example.
    <style>
    .class-one {
    color: <?php the_field(‘colour_one’, ‘option’); ?>;
    }
    .class-two {
    color: <?php the_field(‘colour_two’, ‘option’); ?>;
    }
    3-5 etc…
    </style>

    Then in wordpress options page you can change the HEX code for it which will get pulled through to the class as a HEX value from colour picker.


    Then in select dropdown you just choose the class name as the value, so you never have to load values dynamically through functions.php

    For example:

  • This was one of my functions that loaded values into a select drop down.

    function acf_load_vodka_drink_repeater_field_choices ( $field ) {

    // reset choices
    $field[‘choices’] = array();

    // if has rows
    if( have_rows(‘vodka_master_list’, ‘option’) ) {

    // while has rows
    while( have_rows(‘vodka_master_list’, ‘option’) ) {

    // instantiate row
    the_row();

    // vars
    $title = get_sub_field(‘drink_name’);
    $label = get_sub_field(‘drink_name’);
    $description = get_sub_field(‘description’);
    $alcohol = get_sub_field(‘alcohol_%’);
    $poundsign = ‘£’;

    if( have_rows(‘per_pub_group_pricing’) ) {

    // while has rows
    while( have_rows(‘per_pub_group_pricing’) ) {

    // instantiate row
    the_row();

    // vars
    $id = get_sub_field(‘pub’);
    $small = get_sub_field(’25ml’);
    $medium = get_sub_field(’50ml’);

    //start of if statements

    if (is_page( $id )) {

    if(!empty($small)){
    $drinksizeonewithicon = $poundsign . $small;
    }
    if(!empty($medium)){
    $drinksizetwowithicon = $poundsign . $medium;
    }

    }

    }
    }

    $value = ‘<div class=”titlediv”><h2>’ . $title . ‘</h2></div><div class=”pricediv boxespriceddiv”><div class=”individualprice”><b>’ . $drinksizetwowithicon. ‘</b></div><div class=”individualprice”><b>’ . $drinksizeonewithicon . ‘</b></div><div class=”individualprice”><b></b></div><div class=”individualprice”><b>’ . $alcohol . ‘%</b></div></div><div class=”descriptionclass”><p>’ . $description . ‘</p></div>’;
    // append to choices
    $field[‘choices’][$value] = $label;

    }

    }

    // return the field
    return $field;

    }

    add_filter(‘acf/load_field/key=field_5db8696c5e753’, ‘acf_load_vodka_drink_repeater_field_choices’);

    copy and paste it into your code editor, have a read, could help you out.

  • Hey @trint33 ,

    have you tried using “key=field’ instead of ‘name=’?

    https://www.advancedcustomfields.com/resources/acf-load_field/

    That might do the trick.
    you can get the key name from the custom field you make (you might need to click show key value or something to see it)

  • Hey,

    what is it you’re trying to do? have you got a link to the site / code.
    I might be able to help as I ended up making the web to print project successfully

  • no worries @tjmorris81 I’m using this to make a web to print website. It too is complex for my skill set!

  • @tjmorris81 @hube2 did either of you ever solve this issue? I am pretty much doing the same thing.

    I’ve got a repeater field on an options page, then I’m dynamically putting those values into a checkboxes choices in another field. This works perfectly. But for those values to then be displayed after changing then on the intended wordpress page I need to update those values in the second field after the first field is saved, I have to do this manually at the moment which isn’t good for a clients user experience.

    Look forward to any solutions and would appreciate any advice.

    DD

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