Skip Navigation

[Resuelto] Include "Pending Review" or "Draft" posts inside of Toolset View

This support ticket is created hace 3 años, 3 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.

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por susanT-4 hace 3 años, 3 meses.

Autor
Mensajes
#2150861

How do I include "Pending Review" or "Draft" posts inside of a Toolset View?

I have a toolset form creating a post. That post goes to "pending review" (could be draft if that makes it easier) after form submission. From the user's page, there is a toolset view that shows their posts.

The problem is, after they submit a post, then until that post is published, it is "gone" from the front end. I would like to be able to either add a section to their page that shows posts that are pending review, or include them in the same view as published posts (maybe with a status that says pending or something)

#2151153

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

You can use the Views API to modify the query so that it includes posts with the status pending in the results (or draft, or both).

You'll need to add code such as the following, which you can do at Toolset > Settings > Custom Code.

function ts_filter_query( $query_args, $view_settings, $view_id ){

    if ( $view_id == '123' )
    {
        $query_args['post_status'][] = 'pending';
    }
    
    return $query_args;
}
add_filter( 'wpv_filter_query', 'ts_filter_query', 101, 3 );

Edit the ID of the View where you want to include pending posts in the results.

#2154097

Worked a treat. Thank you!