Skip Navigation

[Resolved] Cannot query the 3rd party custom post

This support ticket is created 5 years, 11 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 2 voices.

Last updated by Beda 5 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#1223342
Screenshot 2019-03-30 at 5.20.50 PM.png

Dear Sir/Madam,

I have a plugin "WP-Invoice", I search it from the database and find the post_type is "wpi_object", at what reason I can't find this post type from View?

How I can query it via View if I already know the post_type?

Best regards,

Kelvin.

#1223359

If the post type is not publicly queryable or somehow hidden, which I strongly suspect given this is a probably private, not public invoice, then you cannot query it in Toolset Views.

If the Post Type is public and queriable then it's also visible in Toolset Views.

#1223390

Dear Beda,

As PHP is open source and it should be able to recode it. As Toolset custom post can also be set as queriable or not. How Toolset enables a custom post being queriable, it should be the same way. Is it possible to let me know?

Best regards,

Kelvin.

#1223398

Toolset does this in the setting Toolset > Post Types > Additional Options.

How a post type is registered when using the WordPress API and PHP is shown here:
https://codex.wordpress.org/Post_Types

Toolset Types creates native WordPress Post Types.

The Post type you mention is not created by Toolset, but likely also registered with native WordPress API.
Hence, you might custom code a solution that will make it public, but you will probably go against the intentions of the author of that code.
It is, however, something that is not covered by Toolset Support, since the support here will help you with Toolset Plugins, not other plugins or custom code.

I'd suggest reaching out to the author of that Post type or plugin, asking them if it's a good idea to make the post type queriable, and if so, if they offer some internal API to do this, or what other suggestion they have for making their content publicly queryable

Note however that I was wrong, actually, we do allow to query (in Views) any kind of post type, even not publicly queriable ones, I just tested this.
It's the argument "'public' => false," in a Post Type's register, that makes it disappears from the Views.
Usually, you can use the WordPress API register_post_type_args() to change the $args of a Post Type.
https://developer.wordpress.org/reference/hooks/register_post_type_args/

But this is not related to Toolset - I cannot craft code for this.