Transformando títulos de post type em meta

Ivon Filho

Procurando desenvolvedor freelancer para seu projeto?

Segue código a ser utilizado na functions.php

function salvar_titulo_personalizado_multiplos($post_id) {
    $post_types = array('pesquisador', 'outro_post_type', 'mais_um_post_type'); // Adicione os post types desejados

    // Verifica se o post pertence a um dos post types definidos e evita revisões
    if (!in_array(get_post_type($post_id), $post_types) || wp_is_post_revision($post_id)) {
        return;
    }

    $titulo = get_the_title($post_id);
    update_post_meta($post_id, 'titulo_jsf', $titulo);
}

add_action('save_post', 'salvar_titulo_personalizado_multiplos');
Rolar para cima