Kaç saattir uğraşıyorum. Denemediğim şey kalmadı ama bir türlü çözemedim.
Emlak adında içerik türüm var ve kategori adında da taxonomy. taxonomy-kategori.php sayfasında kategorilere ait içerikleri listeletiyorum ama sayfalamayı bir türlü çalıştıramadım.
2. sayfa da hep 404 hatası alıyorum.
Kodlar:
Emlak İçerik Türü
register_post_type( 'emlak', array( 'label' => 'Gayri Menkuller', 'description' => 'Emlak İçeriği', 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'capability_type' => 'post', 'hierarchical' => false, 'has_archive' => true, 'menu_icon' => 'dashicons-location', 'rewrite' => array( 'slug' => 'emlak' ), 'query_var' => true, 'exclude_from_search' => false, 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', ), 'labels' => array ( 'name' => 'Emlaklar', 'singular_name' => 'Emlak', 'menu_name' => 'Emlak', 'add_new' => 'İlan Ekle', 'add_new_item' => 'Yeni Emlak Ekle', 'edit' => 'Bilgileri Düzenle', 'edit_item' => 'Emlak Bilgilerini Düzenle', 'new_item' => 'Yeni Emlak', 'view' => 'Emlak Bilgileri', 'view_item' => 'Emlak Bilgileri', 'search_items' => 'Emlaklarda Ara', 'not_found' => 'Aradığınız kriterlere uygun emlak kaydıdı bulunmamaktadır.', 'not_found_in_trash' => 'Silinmiş Emlak kayıdı bulunmamaktadır', 'parent' => 'Üst Emlak', ), ) );Kategori Taxonomy
register_taxonomy('kategori',
array (
0 => 'emlak',
),
array(
'hierarchical' => true,
'label' => 'Kategoriler',
'show_ui' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'public' => true,
'rewrite' =>
array(
'slug' => 'kategori'
),
'singular_label' => 'Kategori'
)
);taxonomy-kategori.php dosyası içeriği<ul class="list-unstyled">
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
'post_type' => 'emlak',
'taxonomy' => $term->taxonomy,
'term' => $term->slug,
'posts_per_page' => 1,
'post_status' => 'publish',
'order' => 'DESC',
'paged' => $paged
);
query_posts( $args );
if (have_posts()) : while (have_posts()) : the_post();
?>
<li class="col-md-6 col-xs-12">
<div class="row">
<div class="col-md-6">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('full', array('class' => 'img-responsive'));
} else {
?>
<img class="img-responsive" data-src="holder.js/100%x120/text:Resim Yok">
<?php } ?>
</div>
<div class="col-md-6">
<h3><?php the_title(); ?></h3>
<div class="meta">
<?php
//Portföy No
$portfoyno = get_post_meta( get_the_ID(), 'gm_portfoyno', true );
if( $portfoyno && !is_wp_error( $portfoyno ) ) {
echo "<span class=\"glyphicon glyphicon-flag\"></span> Portföy No: ".$portfoyno."<br>";
}
//Kredi Bilgisi
$kredi = get_post_meta( get_the_ID(), 'gm_kredi', true );
if ($kredi == "value1") {
echo "<span class=\"glyphicon glyphicon-briefcase\"></span> Krediye Uygun<br>";
} elseif ( $kredi == "value2") {
echo "<span class=\"glyphicon glyphicon-briefcase\"></span> Krediye Uygun Değil<br>";
} else {
echo "";
}
//Bölge
echo "<span class=\"glyphicon glyphicon-map-marker\"></span> ";
$bolge = get_the_terms( $post->ID, 'bolge' );
$count = count($bolge);
if( $bolge && !is_wp_error( $bolge ) ) {
$i = 0;
foreach( $bolge as $term ) {
$i++;
echo $term->name;
if ($i != $count) {
echo " / ";
unset($term);
}
}
}
?>
</div>
<div class="adprice"><div class="pull-right"><a href="<?php the_permalink(); ?>" class="btn btn-danger btn-sm" role="button">İNCELE</a></div><div class="pricetext"><?php echo $fiyat = get_post_meta( get_the_ID(), 'gm_fiyat', true ); ?></div></div>
</div>
</div>
</li>
<?php endwhile; endif; wp_reset_postdata(); ?>
<?php wp_pagenavi(); ?>
</ul>Yardımcı olursanız sevinirim.İyi çalışmalar.