The following examples illustrate how third‑party developers can use these filters to extend the post export and import logic. For more information about the filters, see the Post Export Filter documentation.
Customise export query arguments
Exclude password‑protected posts from being exported by altering the query arguments:
add_filter( 'greyd_export_post_query_args', function( $query_args, $post_id, $args ) {
// Exclude password-protected posts by adding a meta query.
$query_args['has_password'] = false;
return $query_args;
}, 10, 3 );
Modify dynamic meta before export
Convert local file paths to relative URLs when exporting media fields:
add_filter( 'greyd_export_post_meta-dynamic_meta', function( $meta_value, $post_id, $args ) {
// Suppose the meta holds an absolute file URL; convert to relative.
if ( is_string( $meta_value ) && strpos( $meta_value, home_url() ) === 0 ) {
$meta_value = str_replace( home_url(), '', $meta_value );
}
return $meta_value;
}, 10, 3 );
Set imported posts to draft
Force all imported posts to be created as drafts rather than published:
add_filter( 'greyd_import_action', function( $import_action, $post, $existing_post_id ) {
return 'draft';
}, 10, 3 );
Skip unwanted meta keys
Prevent exporting preview meta keys used by Advanced Custom Fields (ACF):
add_filter( 'greyd_export_maybe_skip_meta_option', function( $skip, $meta_key, $meta_value ) {
// Skip ACF preview meta keys
if ( strpos( $meta_key, '_edit_lock' ) === 0 || strpos( $meta_key, '_edit_last' ) === 0 ) {
return true;
}
return $skip;
}, 10, 3 );
Define custom Regex for nested posts
Add a regex pattern to detect a custom block that nests another post ID within its content:
add_filter( 'greyd_regex_nested_posts', function( $patterns, $post_id, $post ) {
$patterns[] = [
'pattern' => '/\[my_custom_block id="([0-9]+)"\]/',
'attribute' => 'id',
];
return $patterns;
}, 10, 3 );