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
- Are blocks that are converted to patterns no longer filterable through the_content?
- “Invalid parameter(s): attributes” issue in context of “blocks.registerBlockType” filter
- Embed dynamic media query in a Gutenberg block
- Adding images to a Bootstrap Carousel with AJAX
- How to change cursor from pointer to finger using jQuery?
- what is __return_false in filters
- Remove “Private” + “:” in title does not work
- Saving Metadata from the Gutenberg Editor Sidebar to the Database
- Where is the proper place to add a filter for pre_get_table_charset?
- Change text of Description in Image Library
- How to always display a specific post from the search result first
- Filter out some plugin action in wp head / wp_footer
- Gutenberg passing block attributes to component in ES6/ESNext
- How to stop wrapping comments in P tag
- html tags in gettext hook get escaped
- Get .subsubsub count of post per status queried using pre_get_posts
- Adaptive product filters for WooCommerce
- How to display the content HTML of a page without displaying the gallery code as well
- How to add drag and drop functionalities to a div inside option panel
- Remove Comment Author Link only for subscribers
- WooCommerce coupon hook argument NULL when using filter woocommerce_get_shop_coupon_data
- How can I edit comment meta value before it is saved?
- Why current_user_can(‘edit_comment’) always true?
- Redirect after post deleted
- How to stop filter from running on the index.php page?
- Filter Shortcodes when using get_page
- Where exactly does the edit_{taxonomy} hook fire?
- Image modification
- Custom Gutenberg color classes naming convention
- Is “document loaded” different on admin side than public side?
- Run `wp_insert_post_data` on all posts
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- How can I pass instance via apply_filters as a parameter?
- register dependency css and js inside a plugin class
- Apply a filter str_replace on specific caracters array in the_content()
- The title of an attachment is not working
- Hide H1 Title using the_title filter
- Filter image and text from post format
- Remove pipe in views admin page filter
- Hooking/Filtering theme name to add theme directory
- How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?
- How can I show a Slot/Fill in the block editor
- How to use parse_query() to add an additional filter based on content to page search?
- FacetWP was unable to auto-detect the post listing : Having an issue with ACF load choices causing FacetWP error
- add_filter – create_function pb in PHP8
- Filter hook for the action of listing users