• Resolved brandoncarson24

    (@brandoncarson24)


    Hello,

    Thank you for developing such a great plugin! We use it on a couple of our websites.

    When using the “Populate with a post type”, is there a way to:

    1. Choose the order of the posts being listed? Right now they come in reverse alpha order.

    2. Choose how the custom post type is saved to the entries section? Right now, it does not save the post name, it saves the post ID. (For example, the entry should say “Web Development” (post name), but instead it says “981” (the post id).

    I look forward to hearing back from you.

    – Brandon

    https://ww.wp.xz.cn/plugins/gravity-forms-custom-post-types/

Viewing 1 replies (of 1 total)
  • Plugin Author Dave from Gravity Wiz

    (@spivurno)

    I’ve added a new hook that will be available in 3.1.1 that allows you to filter the arguments used to fetch the posts. Here is an example that allows you to change the order the posts are listed. Replace “1112” with your form ID and “6” with your field ID.

    add_filter( 'gfcpt_get_posts_args_1112_6', function( $args ) {
    	$args['order'] = 'asc';
    	return $args;
    } );

    It’s a lot more flexible to keep the post ID in the entry rather than the post title because the post ID will never change and changes and be automatically reflected to the entry if the post ID is preserved. My suggestion would be to convert the post ID to the post title when the entry is fetched so you can keep the entry ID in the actual DB and do more with this field.

    add_filter( 'gform_get_input_value_1112_6', function( $value ) {
    	$post = get_post( $value );
    	return $post ? get_the_title( $post ) : $value;
    } );
Viewing 1 replies (of 1 total)

The topic ‘Populate with a post type help’ is closed to new replies.