私はカスタムポストタイプを持っています。カテゴリページを表示しようとしていますので、カテゴリへの標準リンクをクリックすると、そのカテゴリのすべての投稿が表示されます。私はWordPressの階層を見てきましたが、作成する必要のあるテンプレートファイルを見つけることができません...カテゴリページを追加する - CPT - Wordpress
私はこのページを私のカスタムフィールドに引っ張っています:http://ideedev.co.uk/newseed/brand/カスタム投稿タイプ。私がすることによって、この作品を作ることができ、私は、各カテゴリの下にポートフォリオボタンをクリックすると
<?php
/**
* Template name: Main Category Template
*/
?>
<?php get_header(); the_post(); ?>
<!-- Featured Image =========================================== -->
<div class="image-test-container">
<?php if (has_post_thumbnail()) {
// Get the post thumbnail URL
$feat_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
} else {
?>
<style type="text/css">.featured-image{
display:none;
}</style>
<?php
} ?>
<div id="absolute1111" style=" background: url(<?php echo $feat_image; ?>);">
<div class="centerd1111">
<h1><?php the_title(); ?></h1>
</div>
</div>
</div>
<!-- Page Content =========================================== -->
<div class="container">
<div class="row clearfix">
<div class="">
</div>
</div>
<div class="row clearfix">
<div class="level-two-intro-text">
<p><?php the_field('intro_text'); ?></p>
</div>
<div class="level-two-sub-title block__title">
<?php the_field('sub_title'); ?>
</div>
</div>
</div>
<!-- Areas =========================================== -->
<div class="container">
<div class="row clearfix">
<?php if(get_field('areas')): ?>
<?php while(has_sub_field('areas')): ?>
<div class="single-area-item six columns">
<p> <img src="<?php the_sub_field('area_icon'); ?>" style="width:100%;"> <p>
<h2> <?php the_sub_field('area_title'); ?> </h2>
<p> <?php the_sub_field('area_info'); ?> <p>
<div class="area-button"><a href="<?php the_sub_field('button_target'); ?>" class="btn btn--dark-blue" role="button"><?php the_sub_field('button_text'); ?></a></div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
しかし、私はそれがそのカテゴリのページを表示したいと思います...
:コードは、本質的にこれですカテゴリごとに1つのテンプレートページを作成し、特定のカテゴリ内のすべての投稿をループして表示しますが、間違った方法のようです - ちょうどクリックしたカテゴリを表示するテンプレートが1つあるはずです...
正直言って少し混乱していると思います。おかげで探して:)
+++ +++ EDIT
のためにここで私はあなたのためにアーカイブテンプレートを追加できるカスタムポストタイプ...
register_post_type('portfolio', $args);
// Portfolio Categories
$labels = array(
'name' => _x('Portfolio Categories', 'taxonomy general name'),
'singular_name' => _x('Portfolio Category', 'taxonomy singular name'),
'search_items' => __('Search Portfolio Categories'),
'all_items' => __('All Portfolio Categories'),
'parent_item' => __('Parent Portfolio Category'),
'parent_item_colon' => __('Parent Portfolio Category:'),
'edit_item' => __('Edit Portfolio Category'),
'update_item' => __('Update Portfolio Category'),
'add_new_item' => __('Add New Portfolio Category'),
'new_item_name' => __('New Portfolio Category Name'),
'menu_name' => __('Portfolio Category'),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'category'),
);
register_taxonomy('portfolio-category', array('portfolio'), $args);
に応じてそれを編集することができます...あなたは、カスタムポストタイプのデフォルトのカテゴリを使用していますあまりにも?またはカスタム分類法? – Ashkar
これはポートフォリオカテゴリと呼ばれるカスタムですので、ブログや他のアイテムとは別にしておくことができます... –
質問にCPTテキストを追加します。 –