cfz
cfz

Reputation: 343

wordpress custom post template not working

I created another menu in wordpress dashboard, it functions like the post menu, I wanted to apply a customized template to that menu I created. sample, the menu is called "TEchnologies Page", in my editor I created a technologies.php page which initialize the contents I want to display on my technology template, I already registered the the new menu category to functions.php but the problem is wordpress does not recognize the template I created for that menu, when I opened the content type it still has the normal appearance..

I have this code;

functions.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

technologies.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>      

Upvotes: 0

Views: 1902

Answers (1)

Patrick Moore
Patrick Moore

Reputation: 13354

Simply technologies.php by itself is not enough for WordPress to recognize automatically.

You need to rename the theme file archive-technologies.php (for loop) or single-technologies.php (for single post), per the WordPress codex.

Upvotes: 1

Related Questions