最好的选择是使用分类法。
如果EN、DE和FR是术语,那么您可以循环遍历它们,并以每个术语为基础获取页面。
您可以结合一个插件来实现这一点,该插件允许您手动重新排序此类术语。
https://wordpress.org/plugins/i-order-terms/
然后,您可以对代码执行以下操作:
// Get all of the terms in the taxonomy
$countries = get_terms( \'countries\' );
// Check to ensure there are results returned
if ( !empty( $countries ) && !is_wp_error( $countries ) ) {
// Loop through the countries
foreach($countries as $country) {
$args = array(
\'post_status\' => \'publish\',
\'post_type\' => \'page\',
\'countries\' => $country->slug,
)
// Get all of the pages that have this term
$country_pages = new WP_Query($args);
// If there are results then print out the country\'s title and then a list of pages for that country.
if($country_pages->have_posts()) : ?>
<h2><?php echo $country->name; ?></h2>
<ul>
<?php
while($country_pages->have_posts()) : $country_pages->the_post(); ?>
<li><?php the_title() ?></li>
<?php endwhile;
// Ensure that the main query is reset
wp_reset_postdata(); ?>
</ul>
<?php
endif;
}
}