WordPress – adding post category requires page refresh to show up

I have built a new theme on the latest version of WordPress (Version 3.3.1 as of this post).

When adding a new category, (both in a regular post or custom post) the new category doesnt appear, I have to actually refresh the page in order for it to show up. If I am writing a new post that means I need to save / publish a post before I can refresh the page. This is a bit annoying as normally I am used to WordPress adding the new category and updating the page asynchronously so I can then choose the new category straight away.

Read More

Has anyone had this happen to them before? I have kept my theme really light at the moment so not sure what could be causing it. Pretty much all my functions code is for the custom post types I have been making, but the issue is present for standard posts too.

Anyone got any ideas?

EDIT FIXED
I just needed to clean up my functions file by removing some whitespace

Related posts

Leave a Reply

2 comments

  1. I experienced this issue today, and white space in PHP files was the problem.

    However, I want to share the steps I took to resolve the issue:

    1. I tried opening every PHP file and checking for blank lines at the start and end of the file. I picked up a few problems but the issue persisted.
    2. I was also able to do a regex search in my IDE for problems. I used Textmate/Regex: Strip whitespace from beginning/end of file as a reference point and [without quotation marks] the following regex searches “?>[rnt ]+” to find space/blank lines at the end of a file, and “[rnt ]+<?” for the start of a file.
    3. There were still problems so I narrowed down the scope by disabling plug-ins (I also knew it was one of my own plug-ins in the site I’m developing, so that made it easier).
    4. Re-activating a plug-in give a warning “The plugin generated X characters of unexpected output during activation”. This helped me in the trial-and-error process of narrowing down the source.
    5. Once I had the plug-in identified, I started commenting out require_once() calls in PHP files until the “The plugin generated X characters of unexpected output” warning disappeared.
    6. Eventually, I realised I’d broken the plug-in during refactoring and was doing a require_once() on a PHP file that was pure HTML (to inject favicon tags into a page header) rather than the appropriate add_action() call on the file as I originally intended.

    Hopefully, these debug steps provide some inspiration to other people suffering the same problem. As far as I know, WordPress does not offer any easy way to identify the cause of this problem (i.e. it does not identify which file has bad spaces in it).