我试图在仪表板上按类别(我有3个类别)显示我的投资组合我可以创建新的类别/类型,但当我只想列出时"design category" 在公文包页面“找不到内容”
这些代码正常工作。php
function portfolio_s (){
$labels = array(
\'name\' => \'Portfolio\',
\'singular_name\'=>\'Portfolio\',
\'add_new\' => \'Add Item\',
\'all_items\' => \'all Item\',
\'add_new_item\' => \'Add new Item\',
\'edit_item\' => \'edit Item\',
\'new_item\' => \'new Item\',
\'view_item\' => \'view Item\',
\'search_item\' => \'search Item\',
\'not_found\' => \'No Items found\',
\'not_found_in_trash\' => \'No item\',
\'parent_item_colon\' => \'Parent Item\',
);
$args=array(
\'labels\' => $labels,
\'public\' => true,
\'has_archive\' => true,
\'publicly_gueryable\' =>true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array(
\'title\',
\'editor\',
\'excerpt\',
\'thumbnail\',
\'revisions\',
),
\'exclude_from_search\' => false
);
register_post_type( "portfolio", $args );
}
add_action( \'init\', \'portfolio_s\' );
function portfolio_taxonomies() {
$labels = array(
\'name\' => \'Types\',
\'singular_name\' => \'Type\',
\'search_items\' => \'Search Types\',
\'all_items\' => \'All Types\',
\'parent_item\' => \'Parent Types\',
\'parent_item_colon\' => \'Parent Types\',
\'edit_item\' => \'edit Type\',
\'update_item\' => \'update Type\',
\'add_new_item\' => \'Add new Product\',
\'new_item_name\' => \'All Types\',
\'menu_name\' => \'Types\',
);
$args= array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' =>true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => \'type\')
);
register_taxonomy(\'type\', array(\'portfolio\'), $args);
}
add_action(\'init\', \'portfolio_taxonomies\');
此处是公文包文件。
<div class="row">
<?php $query = new WP_Query( array( \'slug\' => \'design\' ) );?>
<?php if($query->have_posts()):?>
<?php while($query->have_posts()) : $query->the_post();?>
<div class="col-md-3 referans-oge">
<a href="<?php the_permalink();?>"><?php the_post_thumbnail(\'thumbnail-large\', array(\'class\'=>\'img-fluid\'));?></a>
</div>
<?php endwhile;?>
<?php else:?>
Content not found
<?php endif;?>