Thanks, this is essentially what I ended up doing. I already had the
variable for the current article because I was using it for other things.
So, I made next and previous variables that incremented and decremented the
current one by one, and did a lot of typing to pull out the information I
needed. Works like a charm now!
On December 31, 2021 4:34:19 PM Dzhovani Chemishanov
<dzhovani.chemishanov@xxxxxxxxx> wrote:
Hi,
It seems that you are using reduce the wrong way. Reduce summarizes an
array to a single value like the sum of it or the product of its
members. What you need is to have a variable keeping the index of the
current article in the array. The next button can have the index +1
and just move you there.
HTH,
Dzhovani
On 12/31/21, Erik Burggraaf <burggraaferik@xxxxxxxxx> wrote:
Hi, I am writing a script to bash some ugly wordpress into shape. My** To leave the list, click on the immediately-following link:-
script is going so well that you had to figure it was only a matter of time
before I ran into something I couldn't handle.
Now I am creating a toolbar that will navigate around a number of
articles. The articles have been swept into an array. The articles each
have an id and a title. I already have a contents panel that uses the ids
and titles just fine, but because it's a contents panel, it made sense to
pull them all out with a loop.. For my navbar, a loop doesn't make sense
because I only need a specific one at a time.
A reduce seems to make sense here. Lets pull out the next article. Then
create a button whose text is the title of the next article, and which uses
the id to proceed to the next article when clicked.
var nextArticle = articles.reduce(...
Then what? I'm having a disconnect understanding what arguments to put in
to get the information I want.
Any tips very much appreciated.
Thanks,