WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] XMLRPC wp.getPostTypes - No custom field info (6 posts)

  1. tinydeskapp
    Member
    Posted 1 year ago #

    XMLRPC method wp.getPostTypes (or any other method) does not seem to return the names of the custom fields associated with a post type.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Exactly what version are you using?

  3. tinydeskapp
    Member
    Posted 1 year ago #

    Sorry, i am testing 3.4 beta 2

  4. Andrew Nacin
    Lead Developer
    Posted 1 year ago #

    Custom fields are arbitrary, so this isn't something that we'd normally do for version 1 of a feature.

    A separate API would probably make sense for this, to query for all custom fields for a particular post type, which would normally show up in the dropdown in the Custom Fields box.

  5. tinydeskapp
    Member
    Posted 1 year ago #

    Hi Andrew,

    There are of course many use cases and hence its not my place to say how it should be and maybe a separate XMLRPC method is the best solution.

    The main issue from our humble perspective is that custom posts have limited value without knowing what the custom fields are. wp.getpostTypes now gives us knowledge of the post types but we can't really use it because we have no way of constructing an input screen that incorporates all the required information to create a post of any given type-- at least without apriori knowledge of the post type on the XMLRPC client side.

    All that being said, the new set of extended XMLRPC methods is otherwise fantastic:) The one further addition of a method to provide details of the relationship b/w custom post types and custom fields will, in my opinion, transform the WordPress platform.

  6. Max Cutler
    Member
    Posted 1 year ago #

    Thanks for the feedback tinydeskapp. We would really love to have included custom field metadata for custom post types, but unfortunately that is not possible with the current WordPress core design.

    Plugins and themes can register new post types without telling WordPress about what custom fields it intends to use; in fact, there is currently no API that tracks this at all. The closest proxy would be to look at admin metabox registrations, but even that is not foolproof.

    You could also try using wp.getPosts to retrieve a sample of posts of the custom post type and then look at the custom_fields value to see which fields are commonly used. Of course, this is not foolproof either, and doesn't give you much information on datatypes or other metadata.

    The methods for 3.4 are primarily intended for when you have apriori knowledge of specific custom post types in your WordPress site(s).

    It'd be great if you (and/or your team) could give some feedback on what specific metadata you'd like to see available. Then for 3.5 we can have a discussion about enhancing core CPT APIs to allow plugins/themes to register such metadata.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags