【发布时间】:2015-01-27 18:30:24
【问题描述】:
我正在使用 get_template_part() 来动态插入 wordpress 页面。我安装了 (m)qTranslate,但除了使用 get_template_part() 的默认语言外,我无法获得任何其他语言。 __() 和 _e() 也没有翻译。
get_template_part() 代码:
$q_config['language'] = $_POST['lang'];
$post_id = $_POST['postId'];
$page_data = get_post( $post_id );
ob_start();
get_template_part( 'page-template/page', $page_data->post_name );
$output .= ob_get_clean();
ob_end_flush();
模板代码示例:
<div>
<?php $the_query = new WP_Query( 'posts_per_page=50' ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<div id="isotope-list">
<?php while ( $the_query->have_posts() ) : $the_query->the_post();
if (in_category( get_category_by_slug( 'designs' )->term_id )) {
$termsArray = get_the_terms( $post->ID, "category" );
$termsString = "";
foreach ( $termsArray as $term ) {
$termsString .= $term->slug.' ';
}
?>
<div class="<?php echo $termsString; ?> item">
<span class="fs-<?php echo $post->ID; ?> ?>"></span>
<div><?php the_title();?></div>
<div class="thumbmail">
<?php
$thumb_url_array = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
echo '<img src="'.$thumb_url.'"/>';
?>
</div>
<span class="description name"><?php _e( 'Click to see more', 'sp' ); ?></span>
</a>
</div>
<?php }
endwhile; ?>
</div>
<?php endif; ?>
</div>
在function.php中我有:
load_child_theme_textdomain('sp', get_stylesheet_directory().'/languages');
有人知道 get_template_part() 是否可以获取本地化以及如何获取?
【问题讨论】: