Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Ayman Bitar
Ayman Bitar
9,462 Points

Custom Post Type Pages not showing after migration

Hello,

I've been following the exact guide for making a wordpress theme. I successfully migrated it, however the inner pages are not working.

Example: Similar to the video in the library, the pages which are /work/xxx don't show up for me.

This is the initial website: aymanbitar.com/zeinaccessories If you navigate through it will be fine, however if you click on any item below, the page will turn white.

After doing some tests, i found the problem is in the single-item.php file, that i use to display the items.

Locally it works perfectly, on the live server it doesn't.

Does anyone have any idea? Or i just repeat the whole project from scratch.

Best, Ayman

13 Answers

Matt Campbell
Matt Campbell
9,767 Points

Have you resaved your permalinks?

Ayman Bitar
Ayman Bitar
9,462 Points

Yes.. I have done every single thing, as the guide was showing.

It even worked on my main website... aymanbitar.com . I was did the exact thing as the tutorials, and it worked. However it doesn't know.

After some speculations, i was thinking maybe the problem is with the pages that i have.

Meaning: In the tutorial, Zac created a work page and a single-work.php page.

In the admin area, he also created a Work page. In my case i have 5 different pages (which are on the main navigation), each page uses the same item template page. [So far it works fine].

However when I click on a single item, i just get taken to a blank page.

I don't know how to track the error, if you can point me in the right direction, then i might be able to solve it. But for now i have no idea.

Sander de Wijs
PLUS
Sander de Wijs
Courses Plus Student 22,267 Points

I think you just need to create a template page single-work.php for displaying a single item. As you say the pages listing all items work ok, but when you click a single item,

Wordpress doesn't know which page to display for a single item just yet. So you have to create one first.

Ayman Bitar
Ayman Bitar
9,462 Points

My Custom post types is called "item". And in my folder there is already a single-item.php file that displays.

My problem is not that it wont show the item page. Locally everything works perfectly, however once i migrate it on a live server, the item page just goes blank. Eventhough the code is still there and nothing is changed.

folder directory

Sander de Wijs
PLUS
Sander de Wijs
Courses Plus Student 22,267 Points

Ok, what you can do is search the wp-options table in the database for any remaining links to your local environment. You can do this via phpMyadmin. Sometimes an error like you are having can be caused by some plugin with a local link in wp-options. At least, that was my experience when migrating WP to a live server.

Ayman Bitar
Ayman Bitar
9,462 Points

Also did that and still no result.

I got the plugin search and replace, replaced all the links from localhost to the new website.

It found 2 in wp-options and 37 in wp-posts.

However the single item pages are still not showing

Sander de Wijs
PLUS
Sander de Wijs
Courses Plus Student 22,267 Points

Strange thing.

Have you checked what happens if you use the non-SEF url's and without .htaccess?

Nice looking site by the way!

Ayman Bitar
Ayman Bitar
9,462 Points

If i remove the SEO friendly links, each item directs me to a link like the the following: " http://aymanbitar.com/zeinaccessoriesfinal/?item=jasmine-turquoise " and is still blank.

Removed the .htcaccess and still blank item pages. =(

This is getting frustrating :(

And Thanks =)

Matt Campbell
Matt Campbell
9,767 Points

Just to start somewhere, have you created a single.php page? And, have you got a bit of code in your functions that spits out what file has been loaded? It looks like it's loading a page that's got no code in it like a blank single.php file.

Ayman Bitar
Ayman Bitar
9,462 Points

Yea i have a single.php page.

It's content is

<?php get_header(); ?>

<p>Single page</p>

<?php get_footer(); ?>

Yea, i was thinking the same, but all the pages that i don't use, have at least the same code as the above snippet. So i should at least get a page. [i would have fixed it, as i would have traced it].

However this is just weird. :(

Matt Campbell
Matt Campbell
9,767 Points

Put this in your functions.php file so you can at least identify what file it is that's causing issue, if it doesn't show up then that also indicates an issue.

add_action('wp_head', 'show_template');

function show_template() {
    global $template;
        echo '<strong>'.$template.'</strong>';
}
Ayman Bitar
Ayman Bitar
9,462 Points

Alright i added it. And still nothing.

Ayman Bitar
Ayman Bitar
9,462 Points

This is the logic of my items, maybe the problem is that.

Basically what i'm doing is that on the navigation i've created 5 pages (Accessory item). Each page follows the item page template..

Whenever i add a new item, i set it to a specific category.

Now on each page, it shows all the items that have the same category as the page. [So far it works fine].

But when i click on an item, it takes me to the empty page.

Should i make the pages different or should the change the type of item? Since the URL is always giving me ?item=xxx which leads to a blank page. This is the last thing i got.

I recreated the website, online. So i don't have to worry about the migration of database and changing values. But the same result.