Wordpress get all posts does not work correctly

Hello,
I have self hosted version of n8n. Lasest release.

I have a problem with wordpress get last posts functionality.
I’d like to collect posts only from 1 month, for example January 2024.
I set it like this.
After 01.01.2024, before 31.01…2024 23:55.

On the results side I get over 2700 results - which is crazy, because we publish max 200 post per month.

I see that it does not react on before statement.
Here is the result:

What did I wrong?
How should I fix it?
Regards
Jacek

1 Like

Hi Jacek_Skowronski welcome to n8n community :n8n:

I try the same filter with wordpress node and no problem, can you try with this http request filter? change your domain and predefine wordpress credential then config your filter date on body request

@Jacek_Skowronski

Yeah I think it’s a bug when using the wordpress node

Using after in a future days works normally.

But if using before then seems not working at all.

That’s exactly what I think.
How can we fix the node?

1 Like

Not quite sure about the node

Maybe flagging it to the n8n team for a closer look.

In the meantime, we’ll need to use the HTTP Request node to call the API, just like @tridi suggested.

2 Likes

How can I create credentials in this case? Is it login and pass or something else?
Regards
Jacek

You can directly use the same credentials you use on the WordPress node.

thanks,
but there is still somethuing wrong
W still get newest posts.

You need to change the date range on the body parameter

date format yyyy-MM-DD

have you try without return all settings ? and put like 250 as limit?

how to handle 18000 records?

Have it the same like You and it still not work


here you say with standard wordpress node you retrieve a lot of post instead of 200 hundred…

What I mean is you can replace it according to your filtering needs. Your filter should be like this, right?

date_query={"after":"2024-01-01","before":"2024-01-31"}

Filter after 1 January 2024 and before 31 January 2024

its not the correcty way

the correct paramters is after and before as query params https://www.agrofakt.pl/wp-json/wp/v2/posts?after=2024-01-01T00:00:00&before=2024-03-01T00:00:00

and you not need credential for retrieve post via GET from a wordpress site except if you protect that endpoint and force credentials.

1 Like

Yes, it’s much closer.
In the n8n I get only 10 results, how to get all from one month?

you can retrieve max 100 per page so if you need more of 100 post per page you need to loop on pagination of collection Posts – REST API Handbook | Developer.WordPress.org

page Current page of the collection.

Default: 1
per_page Maximum number of items to be returned in result set.

Default: 10

Ok, this solution would NOT work for me.
I have sometimes 300, sometimes 500 posts in one month.
REST API returns max 100 entries in batch.
How can I do a loop in N8N to collect for example all post from one year, divided into weeks. So one batch would cover 30-80 posts a week?
or to collect pages in one month?

what is your goal and what do you want to achieve? what are you building? so it’s easier to understand which type of solution we can discuss