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

Kevin Korte
Kevin Korte
28,149 Points

Wordpress permalinks broke yesterday.

So everything was working fine the otherday, now it is not, and I'm not too sure where to go.

I am going to check with my host to ensure mod_rewrite is enabled, but I think it still is as it was as of yesterday morning.

I can see Wordpress updating and changing the .htaccess file in the root of my directory, so that looks okay.

I made a rookie mistake though, I did too many things at once without thinking of checking my permalinks and I'm not sure if one of those things wiped it out.

First was I updated to 3.6.1. I do have the Yoast SEO plugin in, and the W3 cache plug in, both have been disabled and deleted even but it didn't help. (Wasnt sure if those could affect it). Also created a backup of my database and files, however not paying attention I didn't save the backup of before my permalinks got all jacked up. Stupid.

I also had submitted a site map to google under the web developers tools. Again, didnt know if for some reason that could have any problem.

Currently, the permalinks are set to default, and everything works. If I change my permalink structure to basically anything but postname it works. If I change it to postname, instead of picking up the single.php file it picks up the index.php file, and none of the links to other pages work. All I have are the home page and the post listing page (home.php).

Can somebody explain to me what just happened? And/or how to keep this from happening again? I know very little about apache, mod_rewrite, and htaccess.

One other thing I find interesting, in the title tag. My posts are multi-word titles. On default permalinks, I get the whole (post-name | site-name ) in the title like expected. On the postname permalinks, when it throws the index.php file up, if the title starts with a word, I puts in the "post not found" in the title. If the title starts with a number, only the number comes through in the title, but not any of the words that may be after it. What's up with that?

5 Answers

John Locke
John Locke
15,479 Points

Kevin: What site is this?

Derek Hanson
Derek Hanson
7,838 Points

Hi Kevin,

Not know what put into your permalinks section it is hard to say what you did wrong. Here is what I think you might have done. If you used the Custom Structure in the permalinks area and included the full url then you likely broke it. What you want to include is something like: /%postname%/ or /%category%/%postname%/

With WordPress you need to include the types of URLs options they include. This may be another thing that would be causing your problems. If you don't like either of these or they don't seem to work maybe include what you options you chose in your permalinks structure section.

It is not likely that any of the plugins you've listed caused the problem.

Kevin Korte
Kevin Korte
28,149 Points

Hi Derek,

Thanks for the response. I have only played with the pre-set options. I did try /%category%/%postname%/ custom structure and that made the posts work, but not the pages. I haven't put in anything else into the custom box, including the URL, as I do know that is not a good idea. I've read and re-read the codex on permalinks and have seen all the options I can use.

For a few weeks just /%postname%/ was working fine, and that's ideally what I want to get back to.

John Locke
John Locke
15,479 Points

Here's a question, Kevin. Do you have a page.php file? And are the pages of your website all Pages, or are there Posts as well?

Kevin Korte
Kevin Korte
28,149 Points

Yes, I have a page.php file. The pages are the homepage, the posts page that list the machines, the image upload page, and the info upload page (basically the menu items)

For those I have a front-page.php, home.php, page.php.

The actual machines are just posts, using wordpress's default post type with a table plugin and the advance custom fields plugin that I have to upload an image to the post.

That is where it should be registering the single.php file instead of the index.php file, but it's not.

Thanks for the responses so far.

Kevin Korte
Kevin Korte
28,149 Points

Well I nuked my site last night. Database and all. :(

I probably need to learn better patience but I hate being stuck on something for too long. Anyway, I'm salvaging what i can out of backups I had. I'm going to have to rebuild my content I bit but thats okay I guess.

However, my loop and postname permalinks are now working again. I'm dumbfounded and still a little scared I never figured out what caused it.

Thank you all.