Support

Account

Home Forums Bug Reports Fixed settings

Solving

Fixed settings

  • Is there a way to set ACF not to hard set settings? I have had two big issues, with the same reason behind them or so I’m assuming, that I need help with:
    I have had two problems that have made me think ACF hard-sets field information. Is this a bug or normal?

    Initially, I tried to create text boxes using the location rules to “Show this field group if Post Taxonomy is equal to Artificial Intelligence” (artificial intelligence is a hierarchical category option we created). This worked fine until I tried to uncheck ‘artificial intelligence’ and check ‘manufacturing’; the AI text box stayed and just added a manufacturing box, which also couldn’t be removed.

    Another time I tried to changed the field name of our ‘Job Title’ field from ‘title’ to ‘job_title’ to avoid conflict with other programs using title as a name, and once I went into the PHP to change the field name it was calling in, it would no longer call in the ones I initially made. All new posts work but the old ones do not any longer.

    Is there any way to fix this?

  • Hi @greeneinstitute

    For your first issue, I’m not following exactly what you mean. Do you mean you changed the location rule to another term?

    As for changing the fieldname. When you change the fieldname you’re effectively telling ACF and WordPress that the values are going to be saved to a new meta key. The field name is the meta key. So when you changed it the old values are no longer connected to the field. They still exist in the DB tho so if you change it back the values are there.

    My best tip is to always think about the field name the first time around so you’ll avoid issues like this. If you feel like there’s too much job entering the values again you can either run a DB Query to change all meta_keys of “title” to “job_title” OR do some backwards compatibility code when you fetch the info in your theme:

    
    //This will fetch the new job_title if it exists, otherwise it'll try to get the old meta value of "title". If that doesn't exist either $job_title will just be an empty string (NOT a false).
    $job_title = ( get_field('job_title') ? get_field('job_title') : get_post_meta($post_id, 'title', true) );
    
    
  • Thank you.

    This is an example of a consistence issue I’ve run across for different formulas:

    I created a ‘Radio Button’ named ‘Speaker Topics’ (field name: speaker_topics) with the options ‘Artificial Intelligence’ (field name: artificial_intelligence), ‘Manufacturing’ (field name: manufacturing) and ‘3D Printing’ (3d_printing). I created those 3 text areas below, with a ‘Conditional Logic’ setting on each of them to show this field if ‘Speaker Topics’ (the name of the radio button) is equal to their name (for instance, ‘Artificial Intelligence’).

    This, on the backend editor of each post, shows multiple buttons that you can click on and it auto fills the content I put into the ‘default value’ section in ACF. However, now when I click through them, it will pull the content from ‘3D Printing’ for instance, and then if I click ‘Manufacturing’, instead of changing the text, it pulls both (even when the other isn’t clicked).

    Does that make sense? I can clarify if needed.

    Another example was what I briefly explained above and is a similar issue as above:

    I create a ‘text area’ field (‘Artificial Intelligence’ for instance). For each field I set the ‘Location’ to show field group if the ‘Post Taxonomy’ is equal to ‘Artificial Intelligence’. So every time I click the ‘Artificial Intelligence’ category, it enters in a text box. However, when I uncheck ‘Artificial Intelligence’ and update the text editor, the text box goes away on the backend but doesn’t delete on the main speaker page.

    This is the code I’m using the pull them onto the front page:
    echo ‘<div class=”speakerpagetopics333″>’;

    echo ‘<div class=”3dprinting” style=”font-family:Helvetica, Arial, sans-serif;
    font-size: 14px; font-weight: 400;”>’;
    the_field( ‘3d_printing’ ) ; // 3d printing topic field
    echo ‘</div>’ ;

    echo ‘<div class=”manufacturing” style=”font-family:Helvetica, Arial, sans-serif;
    font-size: 14px; font-weight: 400;”>’;
    the_field( ‘manufacturing’ ) ; // manufacturing topic field
    echo ‘</div>’ ;

    echo ‘<div class=”artificialintelligence” style=”font-family:Helvetica, Arial, sans-serif;
    font-size: 14px; font-weight: 400;”>’;
    the_field( ‘ai_field’ ) ; // AI topic field
    echo ‘</div>’ ;

    echo ‘</div>’;
    ?>

  • Also, unfortunately this isn’t just an issue for us. It’s a client issue so it’s not an option to just think about the name. We need a platform that will respond when changed, like the text editor. Because clients aren’t always text savvy.

  • Hi,

    Ah okay now I see. The location rules you set for a field group only applies to the admin interface. That’s how it works. ACF can’t control the displaying of the fields in your theme, that’s up to you. Just because the location rules change and a field is no longer shown that fields previously entered values are not deleted.

    So for example, for you to make sure the entered information only show’s on a post with term “articifialintelligence” you’ll need to check for that yourself in your theme. Example:

    
    <?php 
    $terms = wp_get_post_terms($post->ID, 'taxonomyslug', array('fields' => 'ids'));
    if( in_array( 'artificialintelligence', $terms ) ){
    	
    	//this post is connected to the artificialintelligence term
    	
    }
    
    ?>
    

    ACF is never intended to decide your frontend code for you nor will it delete your field information automatically (that could have catastrophic consequences for many scenarios). ACF main objectives are to (as interpreted by myself) :
    * Provide a great GUI for creating and handling custom meta values in WordPress
    * Provide a simple API for retrieving and/or updating those values

    ACF isn’t a platform tho 🙂 I don’t think it’s customary to let your clients themselves handle creating and changing field groups since it also requires code changes to the frontend theme for the changes to even appear. If they can do all that then there’s almost no need for you as a developer. However if you want to give your clients a descent amount of flexibility you could create all sorts of layouts with the flexible field and let them use that on pages etc. as kind of a modular content system.

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

The topic ‘Fixed settings’ is closed to new replies.