Support » Plugin: Advanced Custom Fields: Extended » Code that used to generate title no longer words – anything changed in codebase

  • Resolved laymonk


    I used code like the following to generate title and slug for a CPT … but it no longer works, and returns a string ‘array-array’.

    Seems something changed. How to adjust the code to keep doing the same ?

    add_filter('acfe/form/submit/post_args/form=add-cpt1', 'add_cpi1_title_and_slug', 10, 4);
    function add_cpi1_title_and_slug($args, $type, $form, $action){
         * Get form input values and build title / slug with them 
        $pos = get_field('position');
        $tenure = get_field('tenure');
        $my_title = $pos . " - " . $tenure;
        $my_slug = sanitize_title($my_title);
        // Change title & slug
        if($type === 'insert_post'){
            $args['post_title'] = $my_title;
    	$args['post_name'] = $my_slug;
        return $args;
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author hwk-fr



    Thanks for the feedback!

    Do a acf_log($pos) & acf_log($tenure) in the hook, and you’ll see what inside the variables. It looks like right now they both return an array, which will not work as you try to concatenate them:

    $my_title = $pos . " - " . $tenure;

    You’ll have to enable WP_DEBUG_LOG in your wp-config.php file in order to use acf_log(). The variables will be logged in /wp-content/debug.log. See documentation:

    If it worked before, then only you will know what has changed since then:

    • Did you upgrade a plugin? WordPress? Theme? Code? Changed field groups? Form settings?
    • What is your WP version? ACF Pro version & ACF Extended version?

    Hope it helps!


    Thread Starter laymonk


    Million thanks for the speedy response, as usual, Konrad … and your suggestion helped me track down the issue.

    acf_log is a most useful function to know about … and it tells me that the fields (which are taxonomy terms) are returning an array of the entire taxonomy referenced instead of the individual term selected.


        [0] => Term-1
        [1] => Term-2

    I configured the field to return the taxonomy term selected, and ticked both ‘Save Terms’ & ‘Load Terms’.

    Well, I unchecked ‘Load Terms’ and the problem went away. Apparently, ‘Load Terms’ load the entire taxonomy terms and I never realized that. DOH!!!

    For what it’s worth, both ACF Pro & ACFE are the current stable versions

    Plugin Author hwk-fr



    I’m glad to hear that you found the root of the problem! Good job.

    Yeah acf_log() is really an amazing function to help debugging code. I’m currently writing an article to help people debugging with ACF. It will be similar to the article from WordPress, but for ACF.

    Have a nice day!


    Thread Starter laymonk


    Thanks again, Konrad …

    I think I will be using acf_log() all the time now.

    Looking forward to reading your article.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Code that used to generate title no longer words – anything changed in codebase’ is closed to new replies.