Why is my theme is randomly stripping the tags out

After taking my older custom theme files over to my computer via FTP I was then able to really dive into what might the problem be.

I put up a maintenance page on my website and worked on where the problem might be coming from, steps to find the culprit code were as follows:

  • Deactivate all plugins and then check out the page in question (for me this was not the issue I was looking for)
  • I then created a new page in my wordpress dashboard and added content, saved and check the page out – my page was still a run on sentence (meaning every page was being affected and not just the one I was trying to edit)
  • I deactivated my custom theme and checked out my page in question with twentytwelve activated. Paragraph breaks were present. So it has to do with my theme. I then activated my theme again to diagnose.
  • I then have to play around with my custom theme templates to be sure I hadn’t taken or added a snippet in there that was affecting my pages. I did this by downloading a new wordpress and moved page.php and index.php to my website theme files. Of course there were some changes to the pages then but I STILL have a run on text on my page in question
  • Last but not least, I decided to work on my themes functions.php file. First I deleted the file from the server through ftp (because we already have a backup on on our computer) and checked out my page in question. It works! So now, it’s time to figure out where in my functions.pgp file the culprit is. I had deleted the top half of the file and uploaded it again, refreshed the page and found out that the code that was causing the issue lays at the bottom half. So from there it was going through each function on the bottom half of my functions.php file until I found the line.

And here it is: remove_filter ('the_content', 'wpautop');

For some reason when I was first working on this theme (back in 2011) I had placed this line of code in my functions.php. Here is what it does. It was basically stripping out any <br> & <p>!

I have since learned while I’m creating my own themes to be sure I organize my files & make comments in my styles.css and function.php files.

This may not be the exact same case for anyone else comign across this problem but the steps to diagnose an issue liek this may be helpful.

Another testing step I was going to be doing if the update with the functions file didn’t work was to rename my .htaccess file to see if there was something in there that might be blocking or disrupting my directory.

I hope this ends up helping others!

Important: Make sure you always have a backup of your database and your wordpress files. You can do this manually or with a trusted wordpress backup plugin. I use BackupBuddy and it’s worth every penny!