我正在为一个房地产经纪人创建一个网站,遇到了一个问题,我认为这是自定义分类法和帖子类型。
自定义帖子类型:PropertyTaxonomy:DistrictExample URL:www.mywebsite。com/listing/[地区]/[标题],www.mywebsite。com/listings/kandy/house1
现状:这很有效,但当我访问www.mywebsite时。我收到一个404错误。我希望在这里显示所有“属性”类型的帖子。
然后我制作了一个自定义页面名(slug)“listings”,希望给它一个类似于博客的模板,用户可以上下浏览。但仍然显示404错误。
(WordPress.org和StackExchange让我来到这里,但我现在有点迷路了,我想问这个问题。)
代码乱七八糟,但到目前为止我得到的是:
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type(\'post_mozeej_property\',
array (
\'labels\' => array (
\'name\' => __(\'Properties\'),
\'singular_name\' => __(\'Property\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Create New Property\'),
\'edit\' => __(\'Edit\'),
\'edit_item\' => __(\'Edit Property\'),
\'new_item\' => __(\'New Property\'),
\'view\' => __(\'View Properties\'),
\'view_item\' => __(\'View Property\'),
\'search_items\' => __(\'Search Properties\'),
\'not_found\' => __(\'No properties found\'),
\'not_found_in_trash\' => __(\'No properties found in trash\')
),
\'description\' => __(\'Add new real-estate property from here!\'),
\'public\' => TRUE,
\'show_ui\' => TRUE,
\'capability_type\' => \'post\',
//\'supports\' => array(\'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\'),
\'publicly_queryable\' => TRUE,
\'exclude_from_search\' => FALSE,
//\'menu_icon\' => get_stylesheet_directory() . \'/images/property_icon.png\',
\'_builtin\' => false,
\'rewrite\' => array( \'slug\' => \'listings/%tx_mozeej_district%\', \'with_front\' => true ),
\'query_var\' => true
)
);
$labels = array(
\'name\' => _x( \'CR Districts\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'CR District\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search CR Districts\' ),
\'all_items\' => __( \'All CR Districts\' ),
\'parent_item\' => __( \'Parent CR Districts\' ),
\'parent_item_colon\' => __( \'Parent CR Districts:\' ),
\'edit_item\' => __( \'Edit CR District\' ),
\'update_item\' => __( \'Update CR District\' ),
\'add_new_item\' => __( \'Add New CR District\' ),
\'new_item_name\' => __( \'New CR District Name\' ),
\'menu_name\' => __( \'CR District\' ),
);
register_taxonomy(\'tx_mozeej_district\', array(\'post_mozeej_property\'), array(
\'hierarchical\' => TRUE,
\'labels\' => $labels,
\'show_ui\' => TRUE,
\'query_var\' => TRUE,
//\'rewrite\' => true,
\'rewrite\' => array( \'slug\' => \'\', \'with_front\' => TRUE ),
));
function filter_post_type_link($link, $post) {
if ($post->post_type != \'post_mozeej_property\')
return $link;
if ($cats = get_the_terms($post->ID, \'tx_mozeej_district\'))
$link = str_replace(\'%tx_mozeej_district%\', array_pop($cats)->slug, $link);
return $link;
}
add_filter(\'post_type_link\', \'filter_post_type_link\', 10, 2);
}
我做错什么了吗?如果有人能帮助我,那就太好了。
提前感谢!