Skip to main content
edited title
Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

Is it possible to filter the Gutenberg editor itself How To Apply Different Styles To All Blocks Based on Post Meta Value?

added 3 characters in body
Source Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

I'm looking for a way to pass post meta data to each of the blocks in the editor for the purpose of styling the content. My actual use case is hard to explain briefly, but for the sake of example, pretend it's the ability to display the post either in dark or light mode depending on a post meta value that the user sets. 

The most obvious way to do this, for me, would be to add a class to the <div class="block-editor"> element like <div class="block-editor dark-editor-mode">. But I don't see an obvious way to do that. Everything I find via search is about modifying the individual blocks, but I want to modify the editor. Is there a hook for this? Either in JS or PHP?

I'm looking for a way to pass post meta data to each of the blocks in the editor for the purpose of styling the content. My actual use case is hard to explain briefly, but for the sake of example, pretend it's the ability to display the post either in dark or light mode depending on a post meta value that the user sets. The most obvious way to do this, for me, would be to add a class to the <div class="block-editor"> element like <div class="block-editor dark-editor-mode">. But I don't see an obvious way to do that. Everything I find via search is about modifying the individual blocks, but I want to modify the editor. Is there a hook for this? Either in JS or PHP?

I'm looking for a way to pass post meta data to each of the blocks in the editor for the purpose of styling the content. My actual use case is hard to explain briefly, but for the sake of example, pretend it's the ability to display the post either in dark or light mode depending on a post meta value that the user sets. 

The most obvious way to do this, for me, would be to add a class to the <div class="block-editor"> element like <div class="block-editor dark-editor-mode">. But I don't see an obvious way to do that. Everything I find via search is about modifying the individual blocks, but I want to modify the editor. Is there a hook for this? Either in JS or PHP?

Source Link
Josiah Sprague
  • 240
  • 1
  • 4
  • 15

Is it possible to filter the Gutenberg editor itself?

I'm looking for a way to pass post meta data to each of the blocks in the editor for the purpose of styling the content. My actual use case is hard to explain briefly, but for the sake of example, pretend it's the ability to display the post either in dark or light mode depending on a post meta value that the user sets. The most obvious way to do this, for me, would be to add a class to the <div class="block-editor"> element like <div class="block-editor dark-editor-mode">. But I don't see an obvious way to do that. Everything I find via search is about modifying the individual blocks, but I want to modify the editor. Is there a hook for this? Either in JS or PHP?