How to export a specific category, or a date range?

Pending

Import WP Pro Updated 1 day ago 7 Replies

Jared asked 1 month ago on December 12, 2024 at 5:31 pm

Good afternoon, 

 

I\’m trying to use this plugin to export a set of specific posts, but I don\’t know what the field name is supposed to be so that I can export only those posts with the category \”Export\”.   

 

It would also be good if I could export specifically my drafts. 

 

Can you please advise me on how to manage the filter portion? 

J

James replied Support Agent

1 month ago on December 12, 2024 at 10:57 pm

Hi Jared,

In the current version of the importer the filter options when exporting are quite limited, however you can modify the exoirt query by using the following code snippet, for example fetching drafts that have the category "Export".

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

    $query['post_status'] = 'draft';
    $query['tax_query'] = [
        [
            'taxonomy' => 'category',
            'field' => 'name',
            'terms' => 'Export'
        ]
    ];

    return $query;
});

If you need help adding code snippets: https://www.importwp.com/docs/using-code-snippets-in-wordpress/

James 

JO

Jared replied privately

1 month ago on December 14, 2024 at 2:21 am

J

James replied Support Agent

1 month ago on December 14, 2024 at 9:42 am

Hi Jared,

Sure, you need to contact codecanyon about this.

James

SO

Sean replied

2 days ago on January 15, 2025 at 2:15 pm

I'm also trying to export a date range from WordPress to JASON but I don't know how to Filter Records - based on the following conditions. What do I put in for 'field name?' (I'm assuming it's date) and what is the date format? yyyy-mm-dd?The best question is: How do I export a date range of posts?Thank you!
J

James replied Support Agent

2 days ago on January 15, 2025 at 3:48 pm

Hi Sean,

To export a date range you would need to add the following code to your website, changing the before and after dates in the format 'Y-m-d', the example will return records between the 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

SO

Sean replied

2 days ago on January 16, 2025 at 11:21 am

Thank you!

Where on the website (what file) do I put the code?

Also, does it export the media into an accompanying folder?

I appreciate your help.

J

James replied Support Agent

1 day ago on January 16, 2025 at 10:16 pm

You can add code to the website via your theme files, or via a custom plugin, or via a code plugin: information on how to do this can be found here: https://www.importwp.com/docs/using-code-snippets-in-wordpress/

No media is not exported into a folder, When you export post type records make sure you select to export the attachment url, as this will allow the importer to use that url to download and import the media.

James