0

I upgraded my Wordpress from 3.8.1 to 3.9.1. I am using the magic-fields-2 plugin for custom data, I have created a custom post type and a custom template for displaying single posts of that type. Everything worked fine before the update. After updating, all posts of this type use index.php in my theme directory.

I have tried creating single-post.php and the posts still use index. I copied my template to a new file, added a template tag to that file, and selected that custom template for a post, that post was rendered using index.php.

I have googled for over an hour without any luck.

Any help or suggestions appreciated.

-- EDIT 1--

The theme is a custom theme of my own making. It is not very complicated, just some custom css and some custom templates. I created the theme in 3.6.x and it has not changed significantly since then.

The template that single posts were using prior to 3.9.1 was single-suites.php (suites is the custom post type). It is still there, but it is being ignored. I copied that file to single-post.php which is supposed to be the next choice in the template hierarchy, but that file is not being used either. I made yet another copy of the same template file, and added a template declaration to it. I edited 3 different posts and selected this template file as the custom template (it was in the template dropdown list), published them and viewed them. All 3 were still using index.php as their template. Finally, I took everything out of the custom template file except the template declaration and an h3 tag just to make sure there were no errors in the template that would cause a problem (my error log was clean, but I was just being cautious). It would still not use the theme.

-- Edit 2 --

I am using the plugin magic-fields-2. That is my only plugin. If I disable that plugin then my custom post type goes away and all the posts associated with that custom post type disappear. These are the posts I'm trying to display I appreciate the questions and hope I have provided enough information to define the problem.

  • What all did you modify in 3.8.1? – eyoung100 May 22 '14 at 19:59
  • How about adding the codes of your custom template file here? Did you try renaming your template file like single-{post_type}.php? – тнє Sufi May 22 '14 at 20:43
  • @тнєSufi I'm thinking that the Installer for 3.9.1 overwrote all his custom work. Before we can tell for sure, I need the OP to compare a file he customized with a the same file in 3.9.1. If that's the case he needs to merge his updates into the stock install. – eyoung100 May 22 '14 at 20:49
  • @ECarterYoung How can a wordpress update overwrite theme files, unless he was using default themes? – тнє Sufi May 22 '14 at 20:53
  • 4
    Are you using any plugins? If so, disable them. Try with a bundled theme like Twenty Fourteen. Does that theme work? Does its template files load correctly? – s_ha_dum May 23 '14 at 3:45
2

Since I don't have your theme I can't find what causing this problem, but this should definitely solve your problem for now

Create content-{post_type}.php file and add your custom-post.

in the index.php add the below code above <?php get_template_part( 'templates/content', 'format'); ?>

<?php if(!in_array(get_post_type(), array('post', 'page', 'attachment', 'nav_menu_item', 'revision'))) ?>
<?php get_template_part( 'content', get_post_type()); ?>

or if you have only custom post type create content-{custom-post-type-slug}.php template file and this to index.php inside loop

<?php 
if(get_post_type() == '{custom-post-type-slug}') :
get_template_part( 'content', {custom-post-type-slug}; 
else :
get_template_part( 'content', 'format'); 
endif; ?>

NOTE: This is only for temporary purpose, until you find a real good solution or why the default template-hierarchy is not working.

EDIT: Install the debug-bar plugin I think you will find what causing the problem with this plugin.

  • @Scott, Did it worked for you? !!! – user2569737 Jun 2 '14 at 12:35
1

I experienced similar case after upgrading to 3.9.1 from 3.8 and I managed to resolve it by simply resubmitting the permalink settings through admin section. Try to apply them again or change them. Hopefully it helps you as well.

  • Can you provide any detail? Which permalink? For each individual post? Did you have to set it to something new, publish, then set it back and publish again? – Scott Jun 6 '14 at 14:26
  • 1
    I'm talking about the global permalink settings, sorry if I wasn't clear. You could change them in "Settings" menu -> "Permalinks" section -> "Save Changes" button, in order to resubmit them without changes of the current setup. Sometimes after migrations or upgrades the permalink settings should be refreshed like that to start working properly again. – SLPh Jun 8 '14 at 0:18
0

copy single.php and rename with single-{{yourposttypename}}.php

like my post type name = "staticblock" my file name for single post single-staticblock.php

see more info enter image description here

  • Your answer, while technically correct, does not help. My original question along with the edits, states that I have tried this. The problem is that wordpress is picking the wrong template. – Scott Jun 1 '14 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.