0
У меня есть создать таможенный пост типа «область» с систематикой «region_country»Показать таможенный пост с пользовательской таксономией
add_action('init', '_init_region_post_type');
function _init_region_post_type() {
register_taxonomy(
'region_country',
array('region'),
array(
'labels' => array(
'name' => __('Countries'),
'singular_name' => __('Country'),
'search_items' => __('Search Countries'),
'popular_items' => __('Popular Countries'),
'all_items' => __('All Countries'),
'parent_item' => __('Parent Countrie'),
'parent_item_colon' => __('Parent Countries:'),
'edit_item' => __('Edit Countrie'),
'update_item' => __('Update Countrie'),
'add_new_item' => __('Add New Countrie'),
'new_item_name' => __('New Countrie'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'hierarchical' => true,
'query_var' => true,
)
);
register_post_type('region',
array(
'capability_type' => 'post',
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'menu_position' => 30,
'labels' => array(
'name' => __('Regions'),
'singular_name' => __('Region'),
'add_new' => __('Add New'),
'add_new_item' => __('Add New Region'),
'edit' => __('Edit Region'),
'edit_item' => __('Edit Region'),
'new_item' => __('New Region'),
'view' => __('View Region'),
'view_item' => __('View Region'),
'search_items' => __('Search Region'),
'not_found' => __('No regions found'),
'not_found_in_trash' => __('No regions found in Trash')
),
'has_archive' => true,
'supports' => array('title', 'page-attributes', 'editor', 'excerpt', 'thumbnail', 'custom-fields'),
'query_var' => true,
)
);
}
Внутри систематики «region_country», я создал «Китай» и «Лаос» как категории или тега (? не знаю)
Я хотел бы, чтобы отображались только сообщения от систематики «регион», где я имел тег/категорию «Китай»
Это то, что я сделал:
<?php
$type = 'region';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1,
'cat' => 'China'
);
$my_query = null;
$my_query = new WP_Query($args);
if($my_query->have_posts()) {
while ($my_query->have_posts()) : $my_query->the_post();
if (has_post_thumbnail()) {
echo "<a href=\""; echo the_permalink(); echo "\" title=\""; echo the_title_attribute(); echo "\" rel=\"external\" >";
echo "<div class=\"thumbnail_image_related_project visible\">";
echo "<div class=\"image\">";
echo the_post_thumbnail();
echo "</div>";
echo "<h2 class=\"transparent_font\">";
echo "<div id=\"indent_text\">";
echo the_title();
echo "</div>";
echo "</h2>";
echo "</div>";
echo "</a><div style=\"height:50px;\"></div>";
}
else
{
echo "<a href=\""; echo the_permalink(); echo "\" title=\""; echo the_title_attribute(); echo "\" rel=\"external\" >";
echo "<div class=\"thumbnail_image_related_project visible\">";
echo "<div class=\"image\"><img width=\"624\" height=\"468\" src=\"http://www.cvdfk.com/images/missing_image.gif\" class=\"attachment-post-thumbnail wp-post-image\" alt=\"china-5-624x468\">";
echo "</div>";
echo "<h2 class=\"transparent_font\">";
echo "<div id=\"indent_text\">";
echo the_title();
echo "</div>";
echo "</h2>";
echo "</div>";
echo "</a><div style=\"height:50px;\"></div>";
}
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Thanks
Этот вопрос, как представляется, не по теме, поскольку речь идет о запросе поддержки настройки стороннего программного обеспечения, здесь именно Wordpress. – hakre