Ready to get started?Download WordPress


Content Types
[resolved] WP_Query and custom fields? (3 posts)

  1. Drivetrain
    Posted 4 years ago #

    Is there a way to specify custom content type fields in the arguments passed to WP_Query() aka query_posts()? E.g:

    $args = array( 'post_type' => 'asset', 'posts_per_page' => -1 );
    $loop = new WP_Query( $args );

    I'd like to be able to use custom fields in WHERE and ORDER BY clauses without writing custom SQL directly. Thanks!


  2. iambriansreed
    Plugin Author

    Posted 4 years ago #

    I am doing that on my site.

    I have a content type called projects and I created a loop of that content type on the projects page template:

    The post_type is the slug of your singular name.
    Does that make sense?

  3. iambriansreed
    Plugin Author

    Posted 4 years ago #

    The next version will allow you to see the content types slug and define it when creating the content type.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic