Developer's Custom Fields
Query Custom Post Type (3 posts)

  1. jonahcoyote
    Posted 3 years ago #

    Hi there, thanks for the great plugin first of all!

    I'm trying to pull in a list of posts for a custom post type and I don't get anything in my select field. Here's my code:

    function register_user_fields() {
    	slt_cf_register_box( array(
    		'type'		=> 'user',
    		'title'		=> 'Member Profile Page',
    		'id'		=> 'profile-page-options',
    		'context'	=> 'normal',
    		'priority'	=> 'high',
    		'fields'	=> array(
    				'name'			=> 'profile-page',
    				'label'			=> 'Profile Page',
    				'type'			=> 'select',
    				'scope'			=> array( 'administrator', 'editor' ),
    				'capabilities'	=> array( 'edit_posts' )
    		'options_type' => 'posts',
    		'options_query' => array(
    			'posts_per_page' => -1,
    			'post_type' => 'member'

    I've got a bunch of members added so there are posts there. Am I doing something wrong?



  2. Steve Taylor
    Plugin Author

    Posted 3 years ago #

    Hi Jonah, what you need to do is put the options_type and options_query parameters inside the array for the profile-page field where they belong! ;-)

    A "box" isn't really a good term for a group of fields on a user screen, but the plugin started life just handling post meta boxes. But still, when you register a box, it's a group of fields, and each field's parameters need to be in its array.

  3. jonahcoyote
    Posted 3 years ago #

    Hey Steve, thanks for the reply, that makes sense and it now works perfectly!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Developer's Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic