Skip Navigation

[Resolved] List all the existing Views using php

This support ticket is created 2 years, 3 months ago. 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.

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)

This topic contains 2 replies, has 2 voices.

Last updated by Paul Marconi 2 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2249985
views.PNG

Hi there,

Is there a way to list all the toolset Views (just the name and slug) using php?
I have created 2 Views under Toolset > Views, but would like to display all the names/ slugs of the Views to a php template.
Is there a way to do that using PHP?

Thank you!

#2250815

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is no way to get view's list you created using Toolset but you should have to run a custom WordPress query where you should query the post type "view" and it will return you all posts with post type view.

As you are using the PHP template, you can query using the WP_Query to find posts belongs to post type "view".

For example:

// WP_Query arguments
$args = array(
	'post_type'              =>  'view',
	'post_status'            =>  'publish' ,
);

// The Query
$query->posts  = new WP_Query( $args );

You will find all the posts belongs to post type view with $query->posts variable. Can you please check if that helps.

#2250903

Thank you Minesh! Using the default WP_Query works to display all created toolset Views.

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.