Limited Number of Posts Exported by Date

Closed

Import WP Pro Updated 1 month ago 1 Reply

Oliver asked 1 month ago on February 27, 2025 at 10:15 am

I\’ve got a website that I\’m migrating and it has in excess of 25,000 posts! We only want to export the previous 5 years worth of posts.

Is there a way we can do this? It would be great if when exporting the posts from the source site we could set a date range to do them in batches.

J

James replied Support Agent

1 month ago on February 27, 2025 at 11:13 am

Hi Oliver,

You can modify the date range of the export by using the following code in your website (between 1st and 15th of january 2025):

add_filter('iwp/exporter/post_query', function ($query) {

    $query['date_query'] = [
        [
            'after' => '2025-01-01',
            'before' => '2025-01-15',
            'inclusive' => true,
        ]
    ];

    return $query;
});

James