How do I get the post ID when renaming?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #100058
    digitalform
    Participant

    Hi Pablo,

    I would like to use the code below as a base.

    add_filter( 'frou_sanitize_file_name', function ( $filename_infs ) {
        $filename_infs['structure']['translation']['my_custom_rule'] = get_current_user_id();
        return $filename_infs;
    }, 20 );

    How do I get back the post ID (not the get_current_user_id)?

    Bets regards,
    Peter

    #101754
    blankPablo
    Moderator
    Plugin Support

    Hi,

    Sorry for the delay.

    You could try to use the function \FROU\WordPress\Post::get_parent_post_id() from the plugin. Example:

    $filename_infs['structure']['translation']['my_custom_rule'] = \FROU\WordPress\Post::get_parent_post_id();
    

    However, it’s not always guaranteed it’s going to work, because it depends on the context.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.