There are issues in the answer marked as correct. It will break the alignment class functionality, and is not actually adding to the classList, instead it is overriding it. And you will only be able to use that one solution for your whole theme.
Instead you can use “registerBlockStyle()” to add a style variation to the list block, and set “isDefault” to true for it to use that class/style but still be able to skip using it, or add a multiple variations if you want.
the wp.domReady() makes sure that it loads when it should and applies the changes
wp.domReady( () => {
wp.blocks.registerBlockStyle( 'core/list', {
name: 'custom-list-style',
label: 'Custom list style',
isDefault: true
} );
} );
Related Posts:
- Remove left alignment option in core/image block
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- How can I filter block registration based on post-type? (Block alignment settings)
- Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?
- This code works, but breaks the media uploader. How do I integrate it in a way that won’t?
- How to add defer=”defer” tag in plugin javascripts?
- How would one modify the filtering Gutenberg applies to pasted content?
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- Why is javascript allowed in my post content?
- How to pass/get data to/from the WooCommerce data-product_variations object?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- Changing text within the Block Editor
- Adding a class to the body_class function
- AJAX filter posts on click based on category
- Add classname to the_category() function?
- Filter Gutenberg Blocks Content
- How to remove google font in WordPress for only single page?
- How do I replace a render_callback function for a block?
- Gutenberg disable the “block” tab in right sidebar
- Where is this inline CSS code [closed]
- How to center oEmbedded content
- How to change the order of HTML output of a core block?
- Add attribute to script loaded by the theme
- When to use add_action when registering/enqueuing scripts
- Gutenberg – Add align controls to a custom block
- Can the wordpress color palettes by changed through Javascript?
- Header image automatically changes depending on season
- Inline Styles on all native blocks
- How to link the whole list item in Gutenberg’s latest posts block?
- add_filter(allowed_block_types) -> adding core/paragraph bugs Gutenberg editor
- Set default terms for new posts / CPTs
- Redirect to another page using contact form 7? [closed]
- Detect when gutenberg editor title is available in Dom after editor load
- Gutenberg Block – Post Featured Image Filter Hook
- Set default value for “Additional CSS class(es)” for specific block types
- Change login CSS
- How to hide/remove GhostKit component panel in gutenberg block inspector
- Filter for author list in gutenberg core editor
- How do I add tags to entire comments, not just their text
- How to optionally append components to the output of a gutenberg block?
- Problem width wp_insert_post_data and Gutenberg block editor
- WordPress Gutenberg core/heading block (wp-block-heading)
- Changing the category for existing Gutenberg blocks
- “The editor has encountered an unexpected error” After add defer tag to java script
- How do I check if I can use the allowed_block_types filter?
- Add an attribute to the root from functions.php with add_filter
- How to add lazy field in content endpoint using Gutenberg blocks
- How to bridge the gap between dynamic back-end data and front-end output?
- Publish button inside custom field group
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- How to add custom HTML attribute to reusable block div in WordPress admin
- How to change this WP logo and posts url in block editor?
- Background color and background image below element in Contact Form 7 – error tip [closed]
- Limit total tags in the_content
- Why is the jquery script not working?
- Disable emojicons introduced with WP 4.2
- How to modify posts_where filter only for the search query
- How to wrap oEmbed-embedded video in DIV tags inside the_content?
- How to add filter with 2 args?
- Any alternate TinyMCE4 themes / subthemes?
- Search content for shortcodes and get parameters
- Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu
- Is there a client side API for handling transients or options?
- How to hook some Unicode texts into calendar widget safely?
- How to add attributes to tag when template cannot be directly modified
- Edit pagination text in the get_the_posts_pagination function
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- When adding buttons to the tinyMCE editor, how do I make them wrap to the next line and/or display in the “Kitchen Sink” area?
- How to add ‘total’ value to custom column title on the posts list page
- Is it possible to use multiple spaces in title?
- create bootstrap columns inside editor group block
- Filter out comments with certain meta key/s in the admin backend
- HTML and custom field variable, inside variable
- WordPress custom admin notice still displays after wp_insert_post_data validation
- Run posts_where and posts_join only on the main query
- run shortcode in excerpt of single custom post type
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- Gutenberg RangeControl
- Add/remove CRON action depending on variable
- Stripping URLs & Email from post submissions
- comment_for() Custom fields not visible when user is logged in
- Access post ID in “content_save_pre”
- prevent HTML output if custom field is empty [closed]
- Gallery stripped from excerpt of post
- BuddyPress – A hook available to hide custom born date on public profile view?
- auth_redirect() doesn’t send users to the page where they orginally tried to acces
- Get the ID of a page in Parent combobox in editor
- Custom sort orderby question
- Change hover to onclick on menu
- How to properly hide the div of an inline collapsible button?
- Add Index to Item in WordPress Gallery
- How to add_filter only when content is not empty?
- Filter template text
- Caching of combined CSS and JS fails because of losing MIME types through combining by PHP
- add_filter not working inside if function
- Element works, but not on wordpress site [duplicate]
- WooCommerce comments_template Filter Not Firing
- Footnotes with dynamic title attributes?
- Filter widget_pages_args not working in Pages Widget