进入wordpress页面的最佳方式——插件还是手册?
好的,我一直在寻找一种简单的方法来为我的客户实现这一点 以下是我试图实现的目标: 不知道该怎么办??我可以很容易地做一个表格,让他们更新 或者我在看GD的星级评定,做一个多集??但我也不确定 有我忽略的东西吗进入wordpress页面的最佳方式——插件还是手册?,wordpress,Wordpress,好的,我一直在寻找一种简单的方法来为我的客户实现这一点 以下是我试图实现的目标: 不知道该怎么办??我可以很容易地做一个表格,让他们更新 或者我在看GD的星级评定,做一个多集??但我也不确定 有我忽略的东西吗 谢谢 以我的经验来看,定制要好得多-提供了更多的灵活性。我经常使用插件,因为最初它为我节省了一些时间,然后70%的时间投入到项目中,我不得不做一些小的修改,结果,我浪费了更多的时间来弄清楚如何以及在哪里进行这些更改,而我本来可以自己编写整个该死的东西。根据我的经验,定制要好得多-提供了更
谢谢 以我的经验来看,定制要好得多-提供了更多的灵活性。我经常使用插件,因为最初它为我节省了一些时间,然后70%的时间投入到项目中,我不得不做一些小的修改,结果,我浪费了更多的时间来弄清楚如何以及在哪里进行这些更改,而我本来可以自己编写整个该死的东西。根据我的经验,定制要好得多-提供了更多的灵活性。我经常使用插件,因为最初它为我节省了一些时间,然后70%的时间投入到项目中,我不得不做一些小的修改,这就浪费了更多的时间去弄清楚如何以及在哪里进行这些更改,而我本来可以自己编写整个该死的东西。你可以为它们创建一个管理页面,为每个轨迹保存变量,特别是好的或坏的,允许编辑或更高级别的用户进行更新。我认为这里的定制解决方案肯定是最好的
如果你登录到,然后转到“我的自我”页面,你会看到那种管理页面,尽管你的页面是所有下拉菜单,而这一个是所有字段。你可以创建一个管理页面,为每个轨迹保存变量,特别是好的或坏的,允许编辑或更高级别的用户更新它。我认为这里的定制解决方案肯定是最好的
如果您登录到,然后转到“我的自我”页面,您将看到这种管理页面,尽管您的页面将是所有下拉菜单,而这一个是所有字段。手动编码最适合这种情况,因此您可以更好地控制所需的功能
并考虑使用POST类型< /P>来构建
http://codex.wordpress.org/Post_Types
要了解有关自定义帖子类型的更多信息,请查看此幻灯片
http://www.slideshare.net/williamsba/custom-post-types-and-taxonomies-in-wordpress
手动编码最适合这种情况,因此您可以更好地控制所需的功能
并考虑使用POST类型< /P>来构建
http://codex.wordpress.org/Post_Types
要了解有关自定义帖子类型的更多信息,请查看此幻灯片
http://www.slideshare.net/williamsba/custom-post-types-and-taxonomies-in-wordpress
不要手动操作我通过“手动”收集,您指的是硬编码,或者让用户通过WYSIWYG编辑器编辑表格 正如每个人都说的那样,按照惯例去做。您需要使用自定义文章类型、自定义分类法和自定义字段 如果您使用插件,则应查找管理自定义帖子类型、自定义分类法和自定义字段的插件,例如: 话虽如此,不使用插件手工编写代码并不困难,应该可以让您更好地理解这些代码是如何组合在一起的 “Trail”应该是自定义的帖子类型。“Trail”帖子类型应该有一个自定义分类“Trail System”,其中包含“Colorado Trail System”、“Fort Lewis Trail System”等。“Trail”帖子类型应该有“condition”和“comments”的自定义字段。尽管“评论”可以存储在帖子正文中 客户端将能够通过Wordpress管理界面添加“跟踪”和“跟踪系统”来更新站点本身,类似于添加“帖子”和“类别”的方式 有道理吗 编辑:下面解释了如何使用原始代码ie,无插件设置上述内容 下面是一些示例代码,应该放在functions.php中。一旦这段代码进入functions.php,“Trails”应该出现在管理界面的“Posts”下面“轨迹系统”应该出现在“轨迹”的下拉菜单中,就像“帖子”的“类别”一样。当您添加一个新的“Trail”时,下面应该有“comments”和“condition”的自定义字段
<?php
// CREATE YOUR CUSTOM POST TYPE
add_action( 'init', 'create_custom_post_type_trail');
function create_custom_post_type_trail() {
// Set all the labels for your custom post type, as they will appear in the wordpress admin interface.
$labels = array(
'name' => _x( 'Trails', 'trail' ),
'singular_name' => _x( 'Trail', 'trail' ),
'add_new' => _x( 'Add New', 'trail' ),
'add_new_item' => _x( 'Add New Trail', 'trail' ),
'edit_item' => _x( 'Edit Trail', 'trail' ),
'new_item' => _x( 'New Trail', 'trail' ),
'view_item' => _x( 'View Trail', 'trail' ),
'search_items' => _x( 'Search Trails', 'trail' ),
'not_found' => _x( 'No Trails found', 'trail' ),
'not_found_in_trash' => _x( 'No Trails found in Trash', 'trail' ),
'parent_item_colon' => _x( 'Parent Trail:', 'trail' ),
'menu_name' => _x( 'Trails', 'trail' ),
);
// Set all the options for your custom post type - you may need to change some of these
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'taxonomies' => array(),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'trails', 'with_front' => false),
'capability_type' => 'post'
);
register_post_type( 'trail', $args );
}
// ADD CUSTOM FIELDS TO THE TRAIL CUSTOM POST TYPE
add_action('wp_insert_post', 'add_custom_trail_fields');
function add_custom_trail_fields($post_id) {
if ( isset($_GET['post_type']) and $_GET['post_type'] == 'trail' ) {
add_post_meta($post_id, 'condition', '', true);
add_post_meta($post_id, 'comments', '', true);
}
return true;
}
// ADD CUSTOM TAXONOMY TO THE TRAIL CUSTOM POST TYPE
add_action( 'init', 'create_trail_taxonomies' );
function create_trail_taxonomies(){
// Set all the labels for your custom taxonomy, as they will appear in the wordpress admin interface.
$labels = array(
'name' => _x( 'Trail Systems', 'taxonomy general name' ),
'singular_name' => _x( 'Trail System', 'taxonomy singular name' ),
'search_items' => __( 'Search Member Categories' ),
'all_items' => __( 'All Member Categories' ),
'parent_item' => __( 'Parent Trail System' ),
'parent_item_colon' => __( 'Parent Trail System:' ),
'edit_item' => __( 'Edit Trail System' ),
'update_item' => __( 'Update Trail System' ),
'add_new_item' => __( 'Add New Trail System' ),
'new_item_name' => __( 'New Trail System Name' ),
'menu_name' => __( 'Trail System' ),
);
// Set all the options for your custom taxonomy - you may need to change some of these
$args = array(
'labels' => $labels,
'label'=>'Trail Systems',
'hierarchical'=>true, // this makes them behave like 'categories' as opposed to like 'tags'
'rewrite' => array('slug' => 'trail_system', 'with_front' => false),
);
register_taxonomy('trail_system', 'trail', $args);
}
/*
// This is for if you make a mistake, and have to unregister a taxonomy and register it with a new name
add_action( 'init', 'unregister_taxonomy');
function unregister_taxonomy(){
global $wp_taxonomies;
$taxonomy = 'XXXXXXXXX'; // name of your taxonomy goes here.
if ( taxonomy_exists( $taxonomy))
unset( $wp_taxonomies[$taxonomy]);
}
*/
?>
您可能会发现其他一些有用的东西:
根据永久链接的设置,您可以通过类似的url访问您的路径
在您的主题中,您可以创建archive-trail.php和single-trail.php文件,以便为归档/单个“trail”帖子创建自定义模板
在循环中,您可以访问自定义的post字段,如下所示:
<?php
$fields = get_post_meta( get_the_ID()); // get all custom fields
echo $fields['comments'][0]; // display 'comments' field
echo $fields['condition'][0]; // display 'condition' field
?>
<?php
$trail_system = get_the_terms( $post->ID, 'trail_system');
echo $trail_system;
?>
同样,在循环内部,获得如下自定义分类:
<?php
$fields = get_post_meta( get_the_ID()); // get all custom fields
echo $fields['comments'][0]; // display 'comments' field
echo $fields['condition'][0]; // display 'condition' field
?>
<?php
$trail_system = get_the_terms( $post->ID, 'trail_system');
echo $trail_system;
?>
最后,我不知道您是否需要对搜索轨迹进行任何操作,但如果需要,请检查以下内容:不要手动操作我通过“手动”收集,您指的是硬编码,或者让用户通过所见即所得编辑器编辑表 正如每个人都说的那样,按照惯例去做。您需要使用自定义文章类型、自定义分类法和自定义字段 如果您使用插件,则应查找管理自定义帖子类型、自定义分类法和自定义字段的插件,例如: 话虽如此,还是用你自己手工编码吧 插件不是很难,它应该能让你更好地理解它是如何组合在一起的 “Trail”应该是自定义的帖子类型。“Trail”帖子类型应该有一个自定义分类“Trail System”,其中包含“Colorado Trail System”、“Fort Lewis Trail System”等。“Trail”帖子类型应该有“condition”和“comments”的自定义字段。尽管“评论”可以存储在帖子正文中 客户端将能够通过Wordpress管理界面添加“跟踪”和“跟踪系统”来更新站点本身,类似于添加“帖子”和“类别”的方式 有道理吗 编辑:下面解释了如何使用原始代码ie,无插件设置上述内容 下面是一些示例代码,应该放在functions.php中。一旦这段代码进入functions.php,“Trails”应该出现在管理界面的“Posts”下面“轨迹系统”应该出现在“轨迹”的下拉菜单中,就像“帖子”的“类别”一样。当您添加一个新的“Trail”时,下面应该有“comments”和“condition”的自定义字段
<?php
// CREATE YOUR CUSTOM POST TYPE
add_action( 'init', 'create_custom_post_type_trail');
function create_custom_post_type_trail() {
// Set all the labels for your custom post type, as they will appear in the wordpress admin interface.
$labels = array(
'name' => _x( 'Trails', 'trail' ),
'singular_name' => _x( 'Trail', 'trail' ),
'add_new' => _x( 'Add New', 'trail' ),
'add_new_item' => _x( 'Add New Trail', 'trail' ),
'edit_item' => _x( 'Edit Trail', 'trail' ),
'new_item' => _x( 'New Trail', 'trail' ),
'view_item' => _x( 'View Trail', 'trail' ),
'search_items' => _x( 'Search Trails', 'trail' ),
'not_found' => _x( 'No Trails found', 'trail' ),
'not_found_in_trash' => _x( 'No Trails found in Trash', 'trail' ),
'parent_item_colon' => _x( 'Parent Trail:', 'trail' ),
'menu_name' => _x( 'Trails', 'trail' ),
);
// Set all the options for your custom post type - you may need to change some of these
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'taxonomies' => array(),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => array('slug' => 'trails', 'with_front' => false),
'capability_type' => 'post'
);
register_post_type( 'trail', $args );
}
// ADD CUSTOM FIELDS TO THE TRAIL CUSTOM POST TYPE
add_action('wp_insert_post', 'add_custom_trail_fields');
function add_custom_trail_fields($post_id) {
if ( isset($_GET['post_type']) and $_GET['post_type'] == 'trail' ) {
add_post_meta($post_id, 'condition', '', true);
add_post_meta($post_id, 'comments', '', true);
}
return true;
}
// ADD CUSTOM TAXONOMY TO THE TRAIL CUSTOM POST TYPE
add_action( 'init', 'create_trail_taxonomies' );
function create_trail_taxonomies(){
// Set all the labels for your custom taxonomy, as they will appear in the wordpress admin interface.
$labels = array(
'name' => _x( 'Trail Systems', 'taxonomy general name' ),
'singular_name' => _x( 'Trail System', 'taxonomy singular name' ),
'search_items' => __( 'Search Member Categories' ),
'all_items' => __( 'All Member Categories' ),
'parent_item' => __( 'Parent Trail System' ),
'parent_item_colon' => __( 'Parent Trail System:' ),
'edit_item' => __( 'Edit Trail System' ),
'update_item' => __( 'Update Trail System' ),
'add_new_item' => __( 'Add New Trail System' ),
'new_item_name' => __( 'New Trail System Name' ),
'menu_name' => __( 'Trail System' ),
);
// Set all the options for your custom taxonomy - you may need to change some of these
$args = array(
'labels' => $labels,
'label'=>'Trail Systems',
'hierarchical'=>true, // this makes them behave like 'categories' as opposed to like 'tags'
'rewrite' => array('slug' => 'trail_system', 'with_front' => false),
);
register_taxonomy('trail_system', 'trail', $args);
}
/*
// This is for if you make a mistake, and have to unregister a taxonomy and register it with a new name
add_action( 'init', 'unregister_taxonomy');
function unregister_taxonomy(){
global $wp_taxonomies;
$taxonomy = 'XXXXXXXXX'; // name of your taxonomy goes here.
if ( taxonomy_exists( $taxonomy))
unset( $wp_taxonomies[$taxonomy]);
}
*/
?>
您可能会发现其他一些有用的东西:
根据永久链接的设置,您可以通过类似的url访问您的路径
在您的主题中,您可以创建archive-trail.php和single-trail.php文件,以便为归档/单个“trail”帖子创建自定义模板
在循环中,您可以访问自定义的post字段,如下所示:
<?php
$fields = get_post_meta( get_the_ID()); // get all custom fields
echo $fields['comments'][0]; // display 'comments' field
echo $fields['condition'][0]; // display 'condition' field
?>
<?php
$trail_system = get_the_terms( $post->ID, 'trail_system');
echo $trail_system;
?>
同样,在循环内部,获得如下自定义分类:
<?php
$fields = get_post_meta( get_the_ID()); // get all custom fields
echo $fields['comments'][0]; // display 'comments' field
echo $fields['condition'][0]; // display 'condition' field
?>
<?php
$trail_system = get_the_terms( $post->ID, 'trail_system');
echo $trail_system;
?>
最后,我不知道你是否需要做些什么来搜索踪迹,但如果需要的话,请查看以下内容:太好了,Josh,非常感谢!如果你不介意的话,我可以看一些示例代码吗?谢谢我刚开始玩自定义的Post类型UI插件。你会推荐这个吗?我根本不用插件。我已经用大量的信息更新了我的答案,所以请查看并让我知道它是否有效。哇,这真是一个很棒的答案!!这确实有助于我理解这个过程。非常感谢你,乔希!!你是一个忍者!!我从来没有使用过它,但是如果你想要一个插件解决方案,我哥哥刚刚告诉我这个插件对管理自定义字段、分类法和帖子类型很有好处:我在花了那么多精力用代码来实现它之后发现了这一点,哈哈。不管怎么说,了解原始代码的方式总是能让你更好地理解这一切,即使你最终使用了一个插件!如果你不介意的话,我可以看一些示例代码吗?谢谢我刚开始玩自定义的Post类型UI插件。你会推荐这个吗?我根本不用插件。我已经用大量的信息更新了我的答案,所以请查看并让我知道它是否有效。哇,这真是一个很棒的答案!!这确实有助于我理解这个过程。非常感谢你,乔希!!你是一个忍者!!我从来没有使用过它,但是如果你想要一个插件解决方案,我哥哥刚刚告诉我这个插件对管理自定义字段、分类法和帖子类型很有好处:我在花了那么多精力用代码来实现它之后发现了这一点,哈哈。不管怎样,了解原始代码的方式总是能让你更好地理解这一切,即使你最终使用了一个插件。