Custom field, loop and pagination
-
Hello guys.
I try to find some help on my own language forum for wordpress but still not found answer … (It’s also for apologize for my bad english..)
So what ùy problem is about ?
Firstly I need to describe how I’m working.
My posts are made like this :
–ID (the number that wordpress generate)
–ID_special (a number that I choice – it’s a custom field)Unlike the ID my posts can have the same ID_special.
I use this ID_special to find post that are the “same” content but in different state (different category in this case, even if they can have some categories in common).
I don’t want my visitors see the same posts in different state. So I write a little function who take in parameter an array and a String.
With this function I can prevent to have the same ‘ID_special‘ post into my output.In my loop I add all ID_special into an array. Then I use my function and if it return true (that’s mean the String (<=> ID_special) is already present in the array) I use
continue;to skip this post.
There is a problem if I do like this : if I writeshowposts=10than it will be (10 – [number of same ID_special]) only on my out.To avoid this I write
showposts=100, add a var that I increment if I don’t skip the post. So after a little if(var == 10) break;It’s working good, in my home page, where I use some loop with different categories.
BUT : now I need to do the same for my archive or category page. It will work fine but the pagination will completly be destroy by how I’m doing with my home page if I use this work way.. And here is my problem.
I look some things about pagination, offset, post__not_in and much more but I still not able to resolve my problem.
It will be really more easy for me if I can edit/change some parameters into my loop (like if my function return true, increment the showposts param).
This is all I think, really sorry for my bad english, if you don’t understand something don’t hesitate to ask me to explain better.
Cordialy exotb
The topic ‘Custom field, loop and pagination’ is closed to new replies.