Support

Account

Home Forums General Issues Taxonomy field not producing result

Unread

Taxonomy field not producing result

    • bjc999

    • May 22, 2020 at 10:38 am

    Taxonomy field not producing result.

    I am using three ACF fields to create and replace the WP page title. It works in WP Admin and on my Elementor website, except ‘$make’ which is a taxonomy.

    The title as per the code below should read ‘Year Make Model’ e.g. 1957 Chevrolet Bel-Air, but it is currently producing a number for the taxonomy, reading ‘1957 12 Bel-Air’.

    My code is in functions.php as I need to change the title in Admin as well.

    Here’s my code:

    add_action(‘acf/save_post’, ‘upd_cust_post_title’, 20);
    function upd_cust_post_title($post_id) {
    $post_type = get_post_type($post_id);
    if ($post_type != ‘cars’) {
    return;
    }
    $year = get_field(‘year’, $post_id);
    $make = get_field(‘make’, $post_id);
    $model = get_field(‘model’, $post_id);
    $post_name = sanitize_title($post_title);
    $post = array(
    ‘ID’ => $post_id,
    ‘post_name’ => $post_name,
    ‘post_title’ => $year . ” ” . $make . ” ” . $model,
    );
    wp_update_post($post);
    }

    Many thanks!

    Edit: I can produce the result on the frontend using Post Terms, but the title change in Admin still has a number instead of $make. Thanks!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.