Skip Navigation

[Resuelto] Custom Post type no title

This support ticket is created hace 7 años, 2 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Etiquetado: 

Este tema contiene 3 respuestas, tiene 2 mensajes.

Última actualización por Minesh hace 7 años, 2 meses.

Asistido por: Minesh.

Autor
Mensajes
#572343

Tell us what you are trying to do? I have a custom post type called Alumni Memorials. I need to create something that will not need a title (if there is a way to autogenerate that is good).

Here is an example of what the page should like like. enlace oculto

Even if there was a way to make the title first_name last_name cast_year automatically that would work. I just don't want them to enter that in the title since the order etc. will be messed up.

Is there any documentation that you are following? NO

#572418

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I would like to know first from where you are adding the posts for post type "Alumni Memorials". Are you adding post from admin or front-end?

From where we can get these field values using which you would like to build the dynamic/automatic title such as first_name last_name cast_year.

#572422

Everything is backend. As I mentioned, it's a custom post type. All the fields are custom fields.

#572457

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Well - you need to use WordPress action hook: save_post

You need to add the following code to your current theme's functions.php file. For example:

function update_venue_concert( $post_id ) { 
    $post_type = get_post_type($post_id);
    if ( "concert" != $post_type ) return;
    $strAllBandList = 'something' . rand(10,100);
    $strConcertTitle = 'CTitle' . rand(10,100);
        $newslug = str_replace('@','at', $strAllBandList);
        write_log('new slug: ' . $newslug);
        $my_post = array(
            'ID' => $post_id,
            'post_title' => $strConcertTitle,
            'post_name' => $newslug
        );
        remove_action('save_post', 'update_venue_concert',20,3);
        wp_update_post($my_post);
        add_action( 'save_post', 'update_venue_concert',20,3);
}
add_action( 'save_post', 'update_venue_concert',20,3);

You can adjust above code as per the need with post type slug and other information.

The related ticket that may help you:
=> https://toolset.com/forums/topic/save_post-with-a-wp_update_post-is-clearing-all-radio-and-checkbox/#post-475158

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/