Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter laportjo

    (@laportjo)

    Ok I found the solution. I put it in my theme functions file :

    function add_votes_field() {
    register_rest_field(
    'idea', 
    'votes', //Field Name in JSON RESPONSE
    array(
            'get_callback'    => function() {
            return get_post_meta( get_the_ID(), 'votes', true );
            }
        )
    );
    }
    add_action( 'rest_api_init', 'add_votes_field' );
    
    function idea_push_update_custom_post_type( $args, $post_type ) {
        if ( $post_type !== 'idea' ) {
             return $args;
        }
    
        // Add additional IDEA CPT options.
        $idea_args = array(
            'show_in_rest' => true,
        );
     // Merge args together.
     return array_merge( $args, $idea_args );
    }
    add_filter( 'register_post_type_args', 'idea_push_update_custom_post_type', 10, 2 );
    Thread Starter laportjo

    (@laportjo)

    Yes they’re not in the POT file.

    When everything will be in the POT file, I’ll be able to transfer you the French version.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)