wordpress ダッシュボードに別のメニューを作成しました。これは投稿メニューのように機能します。作成したメニューにカスタマイズしたテンプレートを適用したかったのです。サンプル、メニューは「技術ページ」と呼ばれます。私のエディターで、技術テンプレートに表示したいコンテンツを初期化する technologies.php ページを作成しました。新しいメニュー カテゴリを functions.php に登録済みですが、問題はwordpress は、そのメニュー用に作成したテンプレートを認識しません。コンテンツ タイプを開くと、通常の外観のままです。
このコードがあります。
関数.php
// category
function TechnologiesRegister() {
$labels = array(
'name' => _x('Technologies', 'post type general name'),
'singular_name' => _x('Technologies', 'post type singular name'),
'add_new' => _x('Add New Technologies', 'portfolio item'),
'add_new_item' => __('Add New Technologies'),
'edit_item' => __('Edit Technologies'),
'new_item' => __('New Technologies'),
'view_item' => __('View Technologies'),
'search_items' => __('Search Technologies'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'thumbnail'),
'rewrite' => true,
'show_in_nav_menus' => false,
);
register_post_type('technologies', $args);
}
add_action('init', 'TechnologiesRegister');
// end category
テクノロジー.php
<?php
/* Template Name: Technologies Page*/
?>
<?php get_header(); ?>
<head>
<style type="text/css">.social-wrap {margin-top: 79px !important;}</style>
</head>
<div class="container technologies">
<div class="row">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('post_type' => 'technologies', 'paged' => $paged, 'posts_per_page' => 500);
query_posts($args);
while (have_posts()) : the_post();
?>
<div class="span3 technologies-icon">
<?php
$attachment_id = get_field('image');
$size = "full";
$image = wp_get_attachment_image_src($attachment_id, $size);
?>
<img src="<?php echo $image[0]; ?>" class="pull-right" />
</div>
<div class="span9 technologies-desc">
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
</div>