...
カスタムポストタイプ、
ステップ1を使用する: は がでこれを貼り付ける...あなたのfunctions.phpファイルを開くと...
<?php
add_theme_support('post-thumbnails'); // enables featured images for posts
add_action('init', 'register_employee_post_type');
function register_employee_post_type() {
register_post_type('Employees',
array(
'labels' => array(
'name' => __('Employees'),
'singular_name' => __('Employee'),
'add_new' => __('Add New'),
'add_new_item' => __('Add New Employee'),
'edit' => __('Edit'),
'edit_item' => __('Edit Employee'),
'new_item' => __('New Employee'),
'view' => __('View Employee'),
'view_item' => __('View Employee'),
'search_items' => __('Search Employees'),
'not_found' => __('No Employees found'),
'not_found_in_trash' => __('No Employees found in Trash'),
'parent' => __('Employee'),
),
'public' => true,
'show_ui' => true,
'publicly_queryable' => true,
'show_in_nav_menus' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'rewrite' => array('slug'=>'employee'),
'supports' => array('title', 'editor', 'thumbnail'),
)
);
flush_rewrite_rules();
}
?>
NOTES:
は、編集して自由に感じる:3210
これは
title //Employee full name
editor //Enable the tinymce editor for bio
thumbnail //Enable the featured image for use with the bio image
は、より多くのオプションのために、このを読んで..これはあなたが必要な場合がありますいくつかのことを含めのみに設定され、新しいポストタイプの従業員 を作成します。あなたが必要なものに近いラベル..
ステップ2: は、新しいページテンプレートを作成します。
/* Template Name: Employees */
ステップ3: スタッフページにテンプレートを適用します。..
ステップ4:あなたが望む任意のフォーマットで クエリすべてのカスタムポストタイプの従業員、 プリントすべての従業員のリスト、トラックにあなたを取得、完全に...
<?php
$args = array('post_type' => 'employees', 'posts_per_page' => -1); //?show all
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
echo '<div class="entry-content">';
echo "<h2>".the_title()."</h2>"; //full name
the_content(); //bio
echo "<div class='employee_image'>".the_post_thumbnail()."</div>"; //image
echo '</div>';
endwhile;
?>
希望:)
マーティ
はWordpress Custom Post Type Generator
を作りました