Replace image name on upload to the new post name on front-end form

You can use sanitize_file_name filter to rename file. put this code in active theme’s functions.php, this will rename image filename as postname if only get title request. I have tested this code and it is working fine. Post name : https://prnt.sc/q3thzw Uploaded renamed image : https://prnt.sc/q3tib7 function make_filename_as_post_name($filename) { $info = pathinfo($filename); $ext = empty($info[‘extension’]) … Read more

How to do the simplest possible frontend ajax call from a plugin?

From codex: wp_ajax_{$action} and wp_ajax_nopriv{$action} the dinamic part {$action} must be the same name as the function, so instead of: add_action( ‘wp_ajax_the_ajax_hook’, ‘the_action_function’ ); add_action( ‘wp_ajax_nopriv_the_ajax_hook’, ‘the_action_function’ ); do: add_action( ‘wp_ajax_the_action_function’, ‘the_action_function’ ); add_action( ‘wp_ajax_nopriv_the_action_function’, ‘the_action_function’ );

Excess dependencies

It looks it was some kind of internal malfunctioning of webpack. After deleting everything from plugin directory (saving src files aside) and again installing @wordpress/create-block, the problem was solved.

How to properly delete custom post type posts programmatically

I believe I found the problem. Since the wp_delete_post was before the redirect, WordPress tried to reload an inexistent page (and comments, since they are deleted automaticaly with the command) and that generated the error. The new code is as such and it’s not generating errors: if( has_post_thumbnail( $post_id ) ) { $imagem_principal_id = get_post_thumbnail_id( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)