ผู้ใช้รายนี้ไม่มีหัวข้อที่ชื่นชอบ.
หัวข้อฟอรั่มที่ชื่นชอบ
สร้างหัวข้อฟอรัมแล้ว
สถานะ |
หัวข้อ
|
ผู้สนับสนุน | เสียง | กระทู้ | ความสดชื่น |
---|---|---|---|---|---|
WordPress Rest API documentation for Posts, Custom Post, Custom Taxonomy
เริ่มโดย: sureshP-3
ใน: English Support
Problem: Solution: https://yoursite.com/wp-json/wp/v2/{taxonomy-slug} To get the list of terms for a taxonomy in a specific language, append the language parameter: https://yoursite.com/wp-json/wp/v2/{taxonomy-slug}?lang={lang_code} For example, to get categories in German: https://yoursite.com/wp-json/wp/v2/categories?lang=de Refer to the WordPress REST API Taxonomies documentation for more details. To retrieve posts from a category based on language, you can use the wpml_object_id filter hook within a loop to get the translated post ID. Here's an example code snippet: $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => 'bob', ), ), ); // The Query. $the_query = new WP_Query( $args ); // The Loop. if ( $the_query->have_posts() ) { echo '<ul>'; while ( $the_query->have_posts() ) { $the_query->the_post(); $my_post_id = get_the_ID(); $my_post_id = apply_filters( 'wpml_object_id', $my_post_id, 'post', false, 'fr' ); //get the post ID in French echo '<li>' . esc_html( get_the_title( $my_post_id ) ) . '</li>'; } echo '</ul>'; } else { esc_html_e( 'Sorry, no posts matched your criteria.' ); } // Restore original Post Data. wp_reset_postdata(); For more information, refer to the wpml_object_id hook documentation and the WP_Query Taxonomy Parameters documentation. Please note that custom code is beyond our support policy. If you need further assistance with custom code, consider contacting one of our certified partners. If this solution doesn't look relevant, please open a new support ticket. |
|
2 | 10 | 1 years, 4 months มาแล้ว | |
WordPress Rest API documentation for Posts, Custom Post, Custom Taxonomy
เริ่มโดย: sureshP-3 ใน: English Support |
|
2 | 2 | 1 years, 4 months มาแล้ว |