Support Forum

Manually changing a post position in a topic thru database

SP sptab
sptab
Member

Hello,

I have a specific situation where I need to insert a post in topic at a specific position in the posts list.

This post should go in position #2 in a topic that has 9 posts.

What I have done is the following:

– create a new post in the topic in the forum

– change the post_index in wp_sfposts table for my new post, change the following posts according (older post 2 becomes 3, 3 becomes 4 and so on)

– change post_count and post_id in wp_sftopics table to reflect my new post change

Unfortunately, my “inserted post #2” stays at the end of the post list, like it’s the newest post. (I also tried changing post_date for my post to insert in wp_sfposts table, it did not help)

What else would be required to move it to second post position in the topic posts list ?

Thank you.

3 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Good try… but. Well you found the but! Topics are actually ordered by their post_id. This is because firstly it does truly represent the order hey were posted in and secondly because being the primary key it is the quickest column on which to sort.

Now – while I am not necessarily recommending it – you can actually change that with a small function in your theme functions file, to use postindex instead. This should be OK – and I stress should be. Put it this way – if it failed then there would need to be some clean up of data anyway! Such a change would also apply to all topics.

If you want to try that I can tell you what you need to do…

SP sptab
sptab
Member

Well, I made the change on the post_id: had to change the autoincrement on the table and renumber all the post_ids after my inserted post.

YS Yellow Swordfish
Yellow Swordfish
Member

Wow. More difficult but safer in the long run.