_:n57f9f49c88204177abef7d46c83c7d5dxb0
<http://schema.org/articleBody>
" \r\n\n\t\t\t\n\t\t\t\n\n\t\t\t\n\n\t\t\t\t\n\t\t\t\tHello, I’m trying to override the default blocks created when using wp_insert_post().\n\n\n\nTo do this I’ve tested on 2 different filter hooks in my custom plugin. My debug logs show that the function is called &amp; the template is being updated. (tribe_events_editor_default_template &amp; tribe_events_editor_default_classic_template) It works fine when using the default “Add New” link.\n\n\n\nHowever, I am still seeing the blocks created on my new Event &amp; looking through the plugin code I cannot figure out why.\n\n\n\nHere is my custom filter hook callback functions:\n\n\n\nfunction wwg_events_editor_template( $template, $post_type, $args ) {error_log( 'Postype: ' . $post_type ); if ( $post_type === Tribe__Events__Main::POSTTYPE ) {error_log( 'Before: ' . print_r($template, TRUE) ); $template = [];$template[] = ['core/paragraph',['placeholder' =&gt; __( 'Add Description...', 'the-events-calendar' ),],];error_log( 'After: ' . print_r($template, TRUE) ); }return $template;}add_filter( 'tribe_events_editor_default_template', 'wwg_events_editor_template', 500, 3 );function wwg_events_class_editor_template( $template ) {error_log( 'Postype: ' . $post_type ); if ( $post_type === Tribe__Events__Main::POSTTYPE ) {error_log( 'Before: ' . print_r($template, TRUE) ); $template = [];$template[] = ['core/paragraph',['placeholder' =&gt; __( 'Add Description...', 'the-events-calendar' ),],];error_log( 'After: ' . print_r($template, TRUE) ); }return $template;}add_filter( 'tribe_events_editor_default_classic_template', 'wwg_events_class_editor_template', 500 );\n\n\n\nHere is what is generated on a new event post:\n\n\n\n&lt;!-- wp:tribe/event-datetime  /--&gt;&lt;!-- wp:tribe/featured-image  /--&gt;&lt;!-- wp:tribe/event-links  /--&gt;&lt;!-- wp:tribe/classic-event-details  /--&gt;&lt;!-- wp:tribe/event-venue  /--&gt;&lt;!-- wp:tribe/tickets --&gt;&lt;div class=\"wp-block-tribe-tickets\"&gt;&lt;/div&gt;&lt;!-- /wp:tribe/tickets --&gt;&lt;!-- wp:tribe/rsvp  /--&gt;&lt;!-- wp:tribe/attendees  /--&gt;\n\n\n\n\n\t\n\t\tThis topic was modified 6 minutes ago by luk3v.\n\t\n\t\n\t\tThis topic was modified 2 minutes ago by luk3v.\n\t\n\n\n\n\n\t\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\r\n\r\n\r\nمشاهده پاسخ های این مطلب\r\n ---------------------------------------------\r\nاین مطلب از سایت انجمن  وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن  وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد\r\nمنبع:  انجمن وردپرس"
<https://iranwebsazan.org/unable-to-override-editor-default-block-template-for-wp_insert_post/>