Keeping array over multiple instances of the same widget
-
Hello dear WordPressers.
I have developed a widget (not to be released, but to make my own life easier) for the blog I’m currently working on. This is a multiple widget where you choose different querys to display lists of and exceptions from posts.
Everything works fine except for my latest addition; i’m trying to make a function to exclude post that have already been displayed in one widget from being displayed in another.
To do this I add all post ID’s from widget1 into an array and then I’m trying to get these from within widget2 and use “continue” if any ID in the array matches the post ID.
I’ve managed to put all the ID’s into the array from widget1, but when I’m trying to get those in widget2 – the array is all cleared and blank.
I’ve checked and I can’t find any reason why the array wouldn’t keep it’s values.The code for the widget is here: https://pastebin.com/f316ccead
The lines of interest are:
97: If the widget is told to put IDs in an array, it’s done here.
105: If the widget is told to exclude post from the array (if it’s set) it’s done here.Some code and print-outs are only there for debugging, so I’ve checked that everything is running properly.
The result can be seen in the sidebar here: https://www.awsm.se
I’d be very grateful if anyone can see why the array doesn’t stay across the different instances of the widget.
Let me know if you don’t understand a word of what I’m saying, my English isn’t always the best ??
Thanks,
Simon.
- The topic ‘Keeping array over multiple instances of the same widget’ is closed to new replies.