2013-09-11 9 views
0

Привет мой английский очень очень плохо извините:) WordPress таможенного поста name=realestate taxonmy name=realestate_cat created.I хотят создать должность список содержания на основе таксономических категорий Моих кодыWordpress Систематика Категория Фильтр

<?php 
    $args = array(
     'post_type'=> 'realestate', 
     'taxonomy' => 'realestate_cat', 
     'cat' => 2, 
    ); 
    query_posts($args); 
    if (have_posts()) : while (have_posts()) : the_post(); 
    ?> 

Этот код делает не работает ...


Мой код функции:

function themes_taxonomy() { 
    register_taxonomy(
     'emlak_kategori', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). 
     'emlak',   //post type name 
     array(
      'hierarchical'  => true, 
      'label'    => 'Emlak Kategorileri', //Display name 
      'query_var'   => true, 
      'rewrite'   => array(
        'slug'   => 'emlak', // This controls the base slug that will display before each term 
        'with_front' => false // Don't display the category base before 
        ) 
      ) 
     ); 
} 
add_action('init', 'themes_taxonomy'); 
function filter_post_type_link($link, $post) { 
    if ($post->post_type != 'emlak') 
     return $link; 

    if ($cats = get_the_terms($post->ID, 'emlak_kategori')) 
     $link = str_replace('%emlak_kategori%', array_pop($cats)->slug, $link); 
    return $link; 
} 
add_filter('post_type_link', 'filter_post_type_link', 10, 2); 
add_action('init', 'register_themepost', 20); 
function register_themepost() { 
    $labels = array(
     'name' => _x('Emlaklar', 'catchthemes_custom_post','catchthemes'), 
     'singular_name' => _x('Theme', 'catchthemes_custom_post', 'catchthemes'), 
     'add_new' => _x('Emlak Ekle', 'catchthemes_custom_post', 'catchthemes'), 
     'add_new_item' => _x('Yeni Bir Emlak Ekle', 'catchthemes_custom_post', 'catchthemes'), 
     'edit_item' => _x('Emlak İlanını Düzenleyin', 'catchthemes_custom_post', 'catchthemes'), 
     'new_item' => _x('Yeni Emlak İlanı', 'catchthemes_custom_post', 'catchthemes'), 
     'view_item' => _x('Emlak İlanınızı Önizleyin', 'catchthemes_custom_post', 'catchthemes'), 
     'search_items' => _x('Emlak Ara', 'catchthemes_custom_post', 'catchthemes'), 
     'not_found' => _x('Henüz Emlak İlanı Eklenmemiş', 'catchthemes_custom_post', 'catchthemes'), 
     'not_found_in_trash' => _x('Çöp Kutusunda Birşey Bulunamadı', 'catchthemes_custom_post', 'catchthemes'), 
     'parent_item_colon' => _x('Parent ThemePost:', 'catchthemes_custom_post', 'catchthemes'), 
     'menu_name' => _x('Emlaklar', 'catchthemes_custom_post', 'catchthemes'), 
    ); 

    $args = array(
     'labels' => $labels, 
     'hierarchical' => false, 
     'description' => 'Emlaklar', 
     'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'post-formats', 'custom-fields'), 
     'taxonomies' => array('post_tag','emlak_kategori'), 
     'show_ui' => true, 
     'show_in_menu' => true, 
     'menu_position' => 5, 
     'menu_icon' => get_stylesheet_directory_uri() . '/images/maidenstower.png', 
     'show_in_nav_menus' => true, 
     'publicly_queryable' => true, 
     'exclude_from_search' => false, 
     'query_var' => true, 
     'can_export' => true, 
     'rewrite' => array('slug' => 'emlak/%emlak_kategori%','with_front' => FALSE), 
     'public' => true, 
     'has_archive' => 'emlak', 
     'capability_type' => 'post' 
    ); 
    register_post_type('emlak', $args);//max 20 charachter cannot contain capital letters and spaces 
} 
+1

что ваш термин таксономии? –

+0

Я действительно не знаю вашего уровня wp/php ... но конкретный код, который вы отправили, если останется таким, ничего не отобразит. вы пытались, например, добавить 'the_title()' или 'echo get_the_ID()'? (и извините меня, если я укажу очевидное .. но на SE вы никогда не узнаете ..) –

ответ

0

вы должны попытаться с термином таксономии, как показано ниже

<?php 
    $args = array(
     'post_type'=> 'realestate', 
     'taxonomy' => 'realestate_cat', 
     'term'=>'your taxonomy term' 
     'cat' => 2, 
    ); 
    query_posts($args); 
    if (have_posts()) : while (have_posts()) : the_title(); the_post(); 
    ?> 
Смежные вопросы