Copy permalink to clipboard automatically when publish/update posts?

Finally, I did it! Use the post_updated_messages hook instead. add_filter( ‘post_updated_messages’, function( $messages ) { // Get the permalink $link = esc_url( get_permalink($post_ID) ); // Copy the permalink automatically $autocopy = ‘<script type=”text/javascript”>navigator.clipboard.writeText(“https://wordpress.stackexchange.com/questions/367921/%s”);</script>’; // `6` is for publishing $messages[‘post’][6] = sprintf( __(‘Post published. <a href=”https://wordpress.stackexchange.com/questions/367921/%s”>View post</a>’. $autocopy), $link, $link); // `1` is for updating $messages[‘post’][1] … Read more

Saving multiple fields (dropdown and text) in custom metabox

It looks like the variable you’re using to set the selected item is not defined in that scope. In your constructor: public function __construct() { if ( is_admin() ) { add_action( ‘load-post.php’, array( $this, ‘init_metabox’ ) ); add_action( ‘load-post-new.php’, array( $this, ‘init_metabox’ ) ); } $this->dropdown_args = [ ‘show_option_none’ => ‘- select a page -‘, … Read more

Execute php after post save/update

I believe you should look into status transitions: https://developer.wordpress.org/reference/hooks/transition_post_status/ There are a couple of examples below the explanation on top of the page. Here’s also some example code of mine: add_action( ‘transition_post_status’, ‘nxt_create_news’, 10, 3 ); // Automatically create a news when a wiki post has been published function nxt_create_news($new_status, $old_status, $nxt_wiki_post) { if(‘publish’ === … Read more

Save post action is called twice

I noticed there was a 302 redirect in my network tab while saving. Save_post was being triggered twice, once from Inside my call, I simply included: $referrer = wp_get_referer(); if (strpos($referrer, ‘http:’) !== false) { error_log(“not the right referrer, aborting”); return; } Issue solved.

Use value from ACF to populate other fields

Untested, but if I understand you correctly, try something like this: $results = new WP_Query( array ( ‘post_id’ => ‘<id-here>’, ‘post_type’ => ‘acf-field’, //not necessary, but insurance ‘post_excerpt’ => ‘<custom-field-name>’, //not necessary, but insurance ‘meta_query’ => array ( ‘key’ => ‘<custom-field-name>’, ) ) );

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