WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cannot Save Category in Blog Post (6 posts)

  1. jaspersone
    Member
    Posted 2 years ago #

    Issue:
    When trying to save or update a post, click on a particular category has no affect. After the page refreshes, the post gets assigned to 'Uncategorized'.

    A temporary work around I have discovered is to go to the Posts page in admin, and select Quick Edit. If a category is selected from that section, (instead of the post page) then the category is saved properly.

    I am developing some plugins using the PageLines API, which seems to have introduced the problem. I was wondering if anyone has experienced this and if there is a work around to the issue.

    Thanks in advance for any advice and help.

  2. amour
    Member
    Posted 2 years ago #

    same issue with version 3.4.1

  3. esmi
    Forum Moderator
    Posted 2 years ago #

    Please post your own topic. You are using a different version of WordPress.

  4. jaspersone
    Member
    Posted 2 years ago #

    I discovered the underlying problem. When using pagelines, the $opt_array in the custom plugin section.php file does not have its own unique namespace. Therefor if keys in the array collide with var names that WordPress uses, in my particular case, it was the variable 'categories', then the conflict will cause WordPress to behave unpredictablely.

    In addition, function section_template() requires its option value names to be unique as well. After adjusting those two things, I no longer have the issue and categories are saving as expected.

  5. Simon Prosser
    Theme Review Admin
    Posted 2 years ago #

    What custom plugin section.php?

    All sections are class based, should be no namespace issues especially with WordPress??

  6. jaspersone
    Member
    Posted 2 years ago #

    @Simon, it's actually two plugins that I am currently writing now called 'events' and 'post highlights'. For the life of me, I could not figure out what was going wrong at first. I had not made any updates to WordPress or PageLines at the time and happen chance discovered the issue a day after I pushed the code to my testing server.

    Needless to say, while testing I also made the same assumption that I could safely use whatever var names I wanted (since sections are class based). After pulling out my hair for half a day and not discovering the cause of the symptoms, I was finally able to get some help from the PageLines support staff. The problem was resolved simply by prefixing my var names with something unique.

    Post mortem, I did a quick diff view and noted the only change between the working and broken files was the unique var names. Switching from the old to new code caused the problem to disappear. Reverting back to the old code caused the problem to reappear. I didn't run any other conclusive tests yet.

    I have been programming in other languages for a while now, but this is my first dive into PHP, so correct me if I'm wrong, but it seems like variable name collision might be causing the issue.

Topic Closed

This topic has been closed to new replies.

About this Topic