wp_insert_post()
.
To do this I’ve tested on 2 different filter hooks in my custom plugin. My debug logs show that the function is called & the template is being updated. (tribe_events_editor_default_template
& tribe_events_editor_default_classic_template
) It works fine when using the default “Add New” link.
However, I am still seeing the blocks created on my new Event & looking through the plugin code I cannot figure out why.
Here is my custom filter hook callback functions:
function 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' => __( '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' => __( '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 );
Here is what is generated on a new event post:
<!-- wp:tribe/event-datetime /-->
<!-- wp:tribe/featured-image /-->
<!-- wp:tribe/event-links /-->
<!-- wp:tribe/classic-event-details /-->
<!-- wp:tribe/event-venue /-->
<!-- wp:tribe/tickets --><div class="wp-block-tribe-tickets">
</div><!-- /wp:tribe/tickets -->
<!-- wp:tribe/rsvp /-->
<!-- wp:tribe/attendees /-->
]]>EditorPlus, do not apear in the template editor, but is working ok in the “Gutenberg editor”
I try to explain myself
When you edit a page or a post you have the EditorPlus interface, but if you use a BlockTheme and try to use it at the theme template EditroPlus do not work. maybe its a feature, no a bug, lol.
Regards from Patagonia
]]> const ALLOWED_BLOCKS = ['core/group', 'core/image', 'core/paragraph', 'core/heading'];
const MY_TEMPLATE = [
['core/group', { lock: { 'move': true, 'remove': false }, allowedBlocks: ['core/heading'] }],
];
return (
<div {...useBlockProps()}>
<InnerBlocks
allowedBlocks={ALLOWED_BLOCKS}
template={MY_TEMPLATE}
/>
</div>
);
Is there a way to do this? If so, how can I accomplish this?
]]>What I want to achieve is to have site with header left and right sidebar, content space and footer, and I want that arrangement on every web page on site. The only thing that should change on every web page should be content part.
I cannot find a way to do that.
All I can do is to edit/create separate templates for page, posts, and other types separately and try to make them look the same. If I want to change general looks of a site, I have to edit each template and make same changes in all of them.
I would expect there is one template I can create that would be applied as default to all content (pages, posts, etc..) unless there is specific template created for some content type.
Is this possible to do at all?
I would like to create a post type template, lock a specific block (prevent delete), but allow others to be added and removed.
I’ve reviewed the following documentation: https://developer.www.ads-software.com/block-editor/reference-guides/block-api/block-templates/#individual-block-locking
Let’s use this as an example:
$template = array(
array( 'core/heading', array(
'placeholder' => 'Add Author...',
) ),
// Allow a Paragraph block to be moved or removed.
array( 'core/paragraph', array(
'placeholder' => 'Add Description...',
'lock' => array(
'move' => true,
'remove' => true,
),
) ),
);
Doing this does enable blocking on the block, however, the blocking can be removed and then the block can be deleted.
It seems that I have to use the template_lock option at the post type template level, which doesn’t help me because I only want to lock one block, not all blocks in the template.
Is there any way to enable template_lock at the individual block level?
Thank you!
Jake
]]>Something like this:
add_action('init', function() {
$page_post_type = get_post_type_object('page');
$page_post_type->template = [
['genesis/my-custom-block'],
];
});
]]>Do you think something like this is possible?
]]>The page content is an empty site-blocks div which makes me think that the site is trying to load a block template for this page?
<div class="wp-site-blocks">
<main class="wp-container-615b6fbcb5cdc wp-block-group"></main>
<style>.wp-container-615b6fbcb5cdc > * {max-width: 100%;margin-left: auto !important;margin-right: auto !important;}.wp-container-615b6fbcb5cdc > .alignwide { max-width: 100%;}.wp-container-615b6fbcb5cdc .alignfull { max-width: none; }.wp-container-615b6fbcb5cdc .alignleft { float: left; margin-right: 2em; }.wp-container-615b6fbcb5cdc .alignright { float: right; margin-left: 2em; }</style>
</div>
I have no idea why it thinks it should load a block template. I am not using full site editing or block templates on this site. I’ve made a copy of this site with all of the same plugins and settings in my local environment and I am not able to reproduce the issue. Any ideas on what would trigger the site to think that it should load a block template for the search results page? I am stumped.
]]>Currently, I’m playing with block templates (https://developer.www.ads-software.com/block-editor/reference-guides/block-api/block-templates/) and manage to define some default attributes with the getwid/images-slider :
['getwid/images-slider', ['imageFit' => 'default', 'imageSize' => 'large-tile', 'showCaption' => true, 'captionPosition' => 'underneath', 'sliderAnimationEffect' => 'fade', 'sliderDots' => 'none']],
Everything work fine except with the imageSize attribute when I’m trying to set a custom image size ( add_image_size() ).
Do you have an idea
Thanks again
Antoine
Sry for my english
]]>My current block template:
array(
'core/heading',
array(
'level' => 1,
'content' => 'This is the page title',
),
),
I have tried things like the following (strong = true):
array(
'core/heading',
array(
'level' => 1,
'content' => 'This is the page title',
'strong' => true,
),
),
But this does not work. Any help?
]]>