std value not loading with block
- This topic has 4 replies, 2 voices, and was last updated 1 hour, 4 minutes ago by
Peter.
-
AuthorPosts
-
January 7, 2026 at 4:38 AM #49597
Paul Wenzel
ParticipantSorry if this is a duplicate - my first post didn't seem to save,,,
'std' value is not loading when the block is added to a gutenberg page. Tried std 2 different ways (including both for illustrative purposes - I tried both individually) Am I missing something?
$meta_boxes[] = [ 'id' => $block_id, 'title' => 'Post - Vertical List', 'type' => 'block', 'icon' => '', 'category' => 'layout', 'supports' => [ 'anchor' => true, ], 'render_template' => get_stylesheet_directory() . '/partials/custom-blocks/posts/post-vertical-list/post-vertical-list.php', 'enqueue_style' => get_stylesheet_directory_uri() . '/partials/custom-blocks/posts/post-vertical-list/post-vertical-list.css', 'fields' => [ [ 'id' => $block_prefix . 'posts_per_page', 'name' => 'Number of Posts', 'type' => 'number', 'std' => 5, 'min' => 1, 'max' => 12, ], $fields['custom_name']['custom_name_text'], $fields['custom_name']['show_name_on_frontend'], [ 'id' => $block_prefix . 'include_images', 'name' => 'Include Images in Lower Posts', 'type' => 'switch', 'style' => 'rounded', 'off_label' => 'No', 'on_label' => 'Yes', 'std' => 'No', ], $fields['auto_pull'], $fields['taxonomy_terms_category'], $fields['taxonomy_terms_tags'] ], 'std' => [ $block_prefix . 'posts_per_page' => 5 ] ];January 7, 2026 at 9:55 PM #49600Peter
ModeratorHello Paul,
Thanks for reaching out.
Can you please remove other fields and recheck this?
'fields' => [ [ 'id' => $block_prefix . 'posts_per_page', 'name' => 'Number of Posts', 'type' => 'number', 'std' => 5, 'min' => 1, 'max' => 12, ] ],and please note that the default value will work if the custom block doesn't have any value, otherwise, it doesn't work.
January 8, 2026 at 1:15 AM #49601Paul Wenzel
ParticipantOkay, after some back and forth:
The taxonomy_terms_category is the culprit, but I can't figure out why.
'fields' => [ [ 'id' => $block_prefix . 'posts_per_page', 'name' => 'Number of Posts', 'type' => 'number', 'std' => 5, 'min' => 1, 'max' => 12, ], $fields['custom_name']['custom_name_text'], $fields['custom_name']['show_name_on_frontend'], [ 'id' => $block_prefix . 'include_images', 'name' => 'Include Images in Lower Posts', 'type' => 'switch', 'style' => 'rounded', 'off_label' => 'No', 'on_label' => 'Yes', 'std' => 'No', ], 'auto_pull' => [ 'id' => $block_prefix . 'auto_pull', 'name' => 'Auto Pull', 'type' => 'radio', 'options' => [ '' => 'None', 'category' => 'Category', 'tag' => 'Tag', ], ], 'taxonomy_terms_category' => [ 'id' => $block_prefix . 'taxonomy_terms_category', 'name' => 'Category', 'type' => 'taxonomy', 'taxonomy' => ['category'], 'field_type' => 'select_advanced', 'placeholder' => 'Select category', 'multiple' => false, 'hidden' => [$block_prefix . 'auto_pull', '!=', 'category'], ], 'taxonomy_terms_tags' => [ 'id' => $block_prefix . 'taxonomy_terms_tags', 'name' => 'Tag', 'type' => 'taxonomy', 'taxonomy' => ['post_tag'], 'field_type' => 'select_advanced', 'placeholder' => 'Select tag', 'multiple' => false, 'query_args' => [ 'hide_empty' => true, 'number' => 0 ], 'hidden' => [$block_prefix . 'auto_pull', '!=', 'tag'], ],If I remove that, it works fine. Any other combination without that works fine, and any combination with that breaks the number_of_posts std (and the std on other fields if I set it, like in include images...)
Any idea why?
January 8, 2026 at 3:28 AM #49602Paul Wenzel
ParticipantUpdate: Changing the category options type from taxonomy to taxonomy_advanced fixed the issue.
January 8, 2026 at 10:03 PM #49603Peter
ModeratorHello,
The
taxonomyfield type will set the post term, like the default Category box of WordPress, so it doesn't work with a custom block or a subfield inside a group field. Refer to the documentation
https://docs.metabox.io/fields/taxonomy/Thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.