Forums

Permanent category id (5 posts)

  1. newkind
    Member
    Posted 3 years ago #

    Hi,

    I've got a code written in my template which determinates if a category with declared id has posts and if so it displays a table. But there's a problem because when some other person imports my wordpress post database (exported from dashboard to xml) the category id's are changing. I could use category names instead of id's but i'd like to preserve availability of changing category name. Is there a way of giving category a permanent id or make it work in other way ?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    I was only thinking about a similar problem earlier today and wishing that categories had an option for custom fields. It would make this sort of semi-intelligent display so much easier and less prone to breakage.

    Are you making any use of the category descriptions? If not, you could use that field to house a keyword and then run a check on that instead.

  3. newkind
    Member
    Posted 3 years ago #

    That's an idea but if you're making a theme for someone else you'd have to inform that person that the category has to have description 'something' etc. so it's troublesome ... Hmmm ... I guess the core team should think about it ...

  4. EMG
    Member
    Posted 3 years ago #

    I'm no php junkie so I have no idea if this would work or not, but would it be possible to code an umbrella if-then statement that would allow the code to simply look and then grab the appropriate categories-with-content without messing with category ids or category titles? Some other way of selection perhaps?

  5. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    I've wracked my brains over this one but so far, haven't come up with a solution - which is a pity as one of my clients needs exactly this kind of functionality. Right now, I've created arrays of keywords and check for their presence in the category titles but that's a far from perfect solution.

Topic Closed

This topic has been closed to new replies.

About this Topic