Php Wordpress自定义post语言WPML
嗨,我有一个自定义类型的职位,它有一个翻译。当我打电话给所有的定制贴子时,我得到了所有的物品。有没有办法检查post设置为哪种语言Php Wordpress自定义post语言WPML,php,wordpress,wpml,Php,Wordpress,Wpml,嗨,我有一个自定义类型的职位,它有一个翻译。当我打电话给所有的定制贴子时,我得到了所有的物品。有没有办法检查post设置为哪种语言 谢谢我想这会对你有所帮助 假设您根据wpml设置了自定义类型的文章:如果您使用的是翻译管理模块,请转到wpml->翻译管理,然后单击多语言内容设置选项卡。否则,如果没有翻译管理模块,您将在WPML->翻译选项下找到这些选项 编辑: 我的内容已经可以翻译了。我想调用php中所有法语自定义帖子。 <?php // set up or arguments for
谢谢我想这会对你有所帮助 假设您根据wpml设置了自定义类型的文章:如果您使用的是翻译管理模块,请转到wpml->翻译管理,然后单击多语言内容设置选项卡。否则,如果没有翻译管理模块,您将在WPML->翻译选项下找到这些选项 编辑:
我的内容已经可以翻译了。我想调用php中所有法语自定义帖子。
<?php
// set up or arguments for our custom query
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
$query_args = array(
'post_type' => 'tutorials',
'posts_per_page' => 5,
'paged' => $paged
);
// create a new instance of WP_Query
$the_query = new WP_Query( $query_args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop
//I try to access to the translated object, where ICL_LANGUAGE_CODE specify the language
$translated = icl_object_id($post->ID,'tutorials',ICL_LANGUAGE_CODE);
?>
<article>
<h1><?php echo get_the_title($translated->ID); ?></h1>
<div class="excerpt">
<?php echo get_the_excerpt($translated->ID); ?>
</div>
</article>
<?php endwhile; ?>
<?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?>
<nav class="prev-next-posts">
<div class="prev-posts-link">
<?php echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages ); // display older posts link ?>
</div>
<div class="next-posts-link">
<?php echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link ?>
</div>
</nav>
<?php } ?>
<?php else: ?>
<article>
<h1>Sorry...</h1>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>