我目前正在为当地的一家日间水疗中心建立一个网站,我在治疗页面上遇到了死胡同。我只是不知道我在做什么,我已经被这个问题困扰了好几个星期了。作为WordPress主题开发的新手,我真的很难做到这一点,因为我不能百分之百确定最好的方法。
这是我想要的布局:
- Treatment Category (Waxing)
- Treatments Within That Category (Half Leg Wax, Full Leg Wax, etc)
我已经设法创建了一个自定义的帖子类型和分类法(假设这是我需要做的),并且我已经成功地创建了治疗类别和治疗本身,但我只是停留在如何将它们实际输出到页面上。
以下是我用来创建自定义帖子类型和分类的代码:
functions.php
function lds_treatment_cpt() {
$labels = array(
\'name\' => _x( \'Treatment\', \'post type general name\' ),
\'singular_name\' => _x( \'Treatment\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New\', \'Treatment\' ),
\'add_new_item\' => __( \'Add New Treatment\' ),
\'edit_item\' => __( \'Edit Treatment\' ),
\'new_item\' => __( \'New Treatment\' ),
\'all_items\' => __( \'All Treatments\' ),
\'view_item\' => __( \'View Treatment\' ),
\'search_items\' => __( \'Search Treatments\' ),
\'not_found\' => __( \'No Treatments Found\' ),
\'not_found_in_trash\' => __( \'No Treatments Found in Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Treatments\'
);
$supports = array(
\'title\',
\'editor\',
\'author\',
\'custom-fields\',
\'post-formats\',
\'comments\',
\'revisions\'
);
$details = array(
\'labels\' => $labels,
\'description\' => \'Everything you want to know about a treatment\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => $supports,
\'has_archive\' => true,
);
register_post_type( \'treatment\', $details );
}
add_action( \'init\', \'lds_treatment_cpt\' );
function lds_treatment_taxonomy() {
$labels = array(
\'name\' => _x( \'Treatment Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Treatment Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Treatment Categories\' ),
\'all_items\' => __( \'All Treatment Categories\' ),
\'parent_item\' => __( \'Parent Treatment Category\' ),
\'parent_item_colon\' => __( \'Parent Treatment Category:\' ),
\'edit_item\' => __( \'Edit Treatment Category\' ),
\'update_item\' => __( \'Update Treatment Category\' ),
\'add_new_item\' => __( \'Add New Treatment Category\' ),
\'new_item_name\' => __( \'New Treatment Category\' ),
\'menu_name\' => __( \'Treatment Categories\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
);
register_taxonomy( \'treatment_category\', \'treatment\', $args );
}
add_action( \'init\', \'lds_treatment_taxonomy\', 0 );
在坚果壳中,我需要知道如何将所有治疗类别输出到一个页面上,然后在另一个页面上显示特定类别内的治疗(如果有意义的话)。
我真的很感谢你的帮助,因为我已经坚持了太久了。
谢谢
Stu:)