0

我在 wordpress 仪表板中创建了另一个菜单,它的功能类似于帖子菜单,我想将自定义模板应用于我创建的那个菜单。示例,菜单名为“TEchnologies Page”,在我的编辑器中,我创建了一个 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>      

4

1 回答 1

1

仅靠technologies.php它本身不足以让 WordPress 自动识别。

您需要根据WordPress codexarchive-technologies.php重命名主题文件(for loop)或single-technologies.php(for single post)。

于 2013-10-31T03:04:44.383 回答