产品/办公室/
返回404错误。这怎么可能呢?如果找不到页面,它是否应该转到索引?
这是我的档案。php文件:
<?php
get_header();
?>
<div id="wrapper">
<main id="main" class="site-main" role="main">
<div class="container">
<?php
get_header();
if(have_posts()) : while(have_posts()) : the_post();
echo \'<a class="a-product" href="\'.get_permalink().\'">\';
echo \'<div class="col col-s-1 col-m-4">\';
the_post_thumbnail( \'large\', array( \'class\' => \'product-img\' ));
echo \'<h2 class="h-product">\';
the_title();
echo \'</h2>\';
// echo substr(get_the_content(), 0, 100).\'...\';
echo \'</div>\';
echo \'</a>\';
endwhile; endif;
?>
</div>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</body>
</html>
这是我的职责。php我做错了什么?
<?php
function create_product_taxonomies() {
$labels = array(
\'name\' => _x( \'Products\', \'taxonomy general name\', \'textdomain\' ),
\'singular_name\' => _x( \'Product\', \'taxonomy singular name\', \'textdomain\' ),
\'search_items\' => __( \'Search Products\', \'textdomain\' ),
\'popular_items\' => __( \'Popular Products\', \'textdomain\' ),
\'all_items\' => __( \'All Products\', \'textdomain\' ),
\'parent_item\' => __( \'Parent product\', \'textdomain\' ),
\'parent_item_colon\' => __( \'Parent product:\', \'textdomain\' ),
\'edit_item\' => __( \'Edit Product\', \'textdomain\' ),
\'update_item\' => __( \'Update Product\', \'textdomain\' ),
\'add_new_item\' => __( \'Add New Product\', \'textdomain\' ),
\'new_item_name\' => __( \'New Product Name\', \'textdomain\' ),
\'separate_items_with_commas\' => __( \'Separate Products with commas\', \'textdomain\' ),
\'add_or_remove_items\' => __( \'Add or remove Products\', \'textdomain\' ),
\'choose_from_most_used\' => __( \'Choose from the most used Products\', \'textdomain\' ),
\'not_found\' => __( \'No Products found.\', \'textdomain\' ),
\'menu_name\' => __( \'Products\', \'textdomain\' ),
);
$args = array(
\'hierarchical\' => true,
\'public\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'has_archive\' => true,
\'rewrite\' => array( \'slug\' => \'products\', \'with_front\' => false ),
);
register_taxonomy( \'product\', [\'product\'], $args );
}
add_action( \'init\', \'create_product_taxonomies\' );
function custom_product_post() {
$labels = array(
\'name\' => __( \'Products\', \'text-domain\' ),
\'singular_name\' => __( \'Product\', \'text-domain\' ),
\'add_new\' => _x( \'Add New Product\', \'text-domain\', \'text-domain\' ),
\'add_new_item\' => __( \'Add New Product\', \'text-domain\' ),
\'edit_item\' => __( \'Edit Product\', \'text-domain\' ),
\'new_item\' => __( \'New Product\', \'text-domain\' ),
\'view_item\' => __( \'View Product\', \'text-domain\' ),
\'search_items\' => __( \'Search Products\', \'text-domain\' ),
\'not_found\' => __( \'No Products found\', \'text-domain\' ),
\'not_found_in_trash\' => __( \'No Products found in Trash\', \'text-domain\' ),
\'parent_item_colon\' => __( \'Parent Product:\', \'text-domain\' ),
\'menu_name\' => __( \'Products\', \'text-domain\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'description\' => \'Wykonane zlecenia\',
\'taxonomies\' => [\'products\'],
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-portfolio\',
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'supports\' => array(
\'title\', \'editor\', \'author\', \'thumbnail\',
\'excerpt\',\'custom-fields\', \'trackbacks\', \'comments\',
\'revisions\', \'page-attributes\', \'post-formats\'
)
);
register_post_type( \'product\', $args );
}
add_action(\'init\', \'custom_product_post\');