Is there a way to get rendered html content of a WP post after updating?
Is there a way to get rendered html content of a WP post after updating?
I found the culprit. I had to change the nonce check in save_custom_post_type() to: if ( !isset( $_POST[‘metabox_nonce’] ) || !wp_verify_nonce( $_POST[‘metabox_nonce’], basename( __FILE__ ) ) ) { return $post_id; }
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
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
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
Custom taxonomy only gets saved in quick edit
I found what was the problem. the code with actions were wrapped bu this following code : global pagenow; if ( $pagenow === “edit.php” && isset( $_GET[‘post_type’] ) ){} When there is an ajax call, $pagenow === admin-ajax.php and $_GET === [ [“_fs_blog_admin”]=> string(4) “true” ] so that could not be fired.
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.
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>’, ) ) );
Post and Pages section inside WordPress admin are completely blank
Is there a way to get rendered html content of a WP post after updating?