Describe the bug
Since WordPress 7.x (tested with WP 7.x + Gutenberg), the attributes.align field on CoreParagraph and CoreHeading blocks always returns null via GraphQL, even when a text alignment is explicitly set in the editor.
The only workaround is to query attributes.cssClassName, parse the resulting string for a has-text-align-* class, and extract the alignment value manually — which is brittle and should not be necessary.
To Reproduce
- Create a post with a Paragraph or Heading block
- Set a text alignment (e.g. center or right) via the block toolbar in the editor
- Query the block via WPGraphQL Content Blocks:
query {
post(id: "...", idType: DATABASE_ID) {
editorBlocks {
... on CoreParagraph {
attributes {
align
cssClassName
}
}
... on CoreHeading {
attributes {
align
cssClassName
}
}
}
}
}
Expected behavior
attributes.align should return the text alignment value set in the editor (e.g. "center", "right"), consistent with how the block attribute is defined in block.json.
Actual behavior
attributes.align is always null.
attributes.cssClassName correctly contains the alignment class (e.g. "has-text-align-center"), which can be used as a workaround — but requires manually parsing the class string:
const align = cssClassName
?.split(' ')
.find(c => c.startsWith('has-text-align-'))
?.replace('has-text-align-', '') ?? null;
Environment
- WordPress version: 7.0
- WPGraphQL version: 2.16.0
- WPGraphQL Content Blocks version: 4.8.5
Additional context
It appears that WordPress 7.x changed how the text alignment for headings is presented in the GraphQL schema. In the editor, the value is stored in textAlign but in GraphQL it is only available in the align attribute (which is currently always null).
Describe the bug
Since WordPress 7.x (tested with WP 7.x + Gutenberg), the
attributes.alignfield onCoreParagraphandCoreHeadingblocks always returnsnullvia GraphQL, even when a text alignment is explicitly set in the editor.The only workaround is to query
attributes.cssClassName, parse the resulting string for ahas-text-align-*class, and extract the alignment value manually — which is brittle and should not be necessary.To Reproduce
Expected behavior
attributes.alignshould return the text alignment value set in the editor (e.g."center","right"), consistent with how the block attribute is defined inblock.json.Actual behavior
attributes.alignis alwaysnull.attributes.cssClassNamecorrectly contains the alignment class (e.g."has-text-align-center"), which can be used as a workaround — but requires manually parsing the class string:Environment
Additional context
It appears that WordPress 7.x changed how the text alignment for headings is presented in the GraphQL schema. In the editor, the value is stored in
textAlignbut in GraphQL it is only available in thealignattribute (which is currently alwaysnull).