이 사용자는 즐겨찾는 주제가 없습니다.
즐겨찾는 포럼 주제
포럼 주제가 생성되었습니다.
상태 |
주제
|
서포터 | 목소리 | 게시물 | 선도 |
---|---|---|---|---|---|
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 년, 4 월 전에 | |
WordPress Rest API documentation for Posts, Custom Post, Custom Taxonomy
시작한 사람: sureshP-3 안에: English Support |
|
2 | 2 | 1 년, 5 월 전에 |