• Resolved blgleadoff

    (@blgleadoff)


    Hello,

    I have created a Custom Post Type “faq” in my function.php, I can translate it, but when I go to the https://www.myafterme.com/en/wp-json/wp/v2/faq/91 I cannot get the translation. Do I miss something ? I cannot find any anwser to my question.

     $labels = array(
            'name'               => 'Foire aux questions',
            'singular_name'      => 'Question fréquente',
            'menu_name'          => 'FAQ',
            'name_admin_bar'     => 'Question fréquente',
            'add_new'            => 'Ajouter',
            'add_new_item'       => 'Ajouter une nouvelle question fréquente',
            'new_item'           => 'Nouvelle question fréquente',
            'edit_item'          => 'Éditer la question fréquente',
            'view_item'          => 'Voir la question fréquente',
            'all_items'          => 'Toutes les questions fréquentes',
            'search_items'       => 'Rechercher des questions fréquentes',
            'parent_item_colon'  => 'Question fréquente parente :',
            'not_found'          => 'Aucune question fréquente trouvée.',
            'not_found_in_trash' => 'Aucune question fréquente trouvée dans la corbeille.'
        );
    
        $args = array(
            'labels'             => $labels,
            'public'             => true,
            'publicly_queryable' => true,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'show_in_rest'       => true,
            'query_var'          => false,
            'capability_type'    => 'post',
            'has_archive'        => false,
            'hierarchical'       => false,
            'menu_position'      => null,
            'rewrite'            => array('slug' => 'faq'),
            'supports'           => array('title', 'thumbnail','editor'),
            'menu_icon'          => 'dashicons-testimonial',
        );
    
        register_post_type('faq', $args);

    Best regards

    • This topic was modified 2 years, 8 months ago by blgleadoff.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    Did you use the latest version of our plugin?

    The rest-api is processed through the translation engine in TranslatePress. So you can access it at /de/wp-json/wp/v2/posts?197/, for example, where 197 is the id of the post.
    Basically, every REST endpoint is processed when accessed via the language prefix.

    Thread Starter blgleadoff

    (@blgleadoff)

    Hi,

    Yes, I’m on the 2.7.0, the latest I can see.

    Sorry, have you seen the link https://www.myafterme.com/en/wp-json/wp/v2/faq/91 ?

    This is a real project, and I already did the translation in the back office.

    We can see, that the slug has changed but not the rest. This is a Custom Post Type, do I need to do something or do I have any issue on capabilities or something else ?

    Best regards,

    Thread Starter blgleadoff

    (@blgleadoff)

    Hello,

    Since I had no anwser from you, I search for a few hours and I found were was the issue, when you register the post type, make sure to put a priority on the add_action(‘init’, ‘register_faq_post_type’, 1);

    In this case, you will see the translation in the API.

    Is it the right way to do it ?

    Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    I will bring more details on this topic next week.


    Thank you for understanding.

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

The topic ‘API – Translation for CPT’ is closed to new replies.