Skip to main content

Timeline for Attributes array not saving values

Current License: CC BY-SA 4.0

14 events
when toggle format what by license comment
Feb 19 at 10:54 vote accept Dave B
Feb 16 at 14:13 comment added Tom J Nowell you can fetch posts via hooks but it's easier to use a query block and a post template which it looks like you figured out on your own! Anytime you can repurpose core blocks and patterns/templates is a huge time save, especially if you can eliminate the block entirely for a pattern
Feb 16 at 11:17 answer added Dave B timeline score: 0
Feb 16 at 11:13 comment added Dave B Thanks @TomJNowell - I was able to create a template and use the latest post core block to achieve what I want.
Feb 16 at 10:15 comment added Dave B Thanks @TomJNowell - Would this work with getting my blog post? Hence apiFetch. Then dynamically populate the blocks with the blogs with that certain tag? Do you have an article on getting entity records? I am more of a visual person
Feb 16 at 10:10 comment added Tom J Nowell also, you can declare your block supports colour and background styles, don't reinvent that yourself with custom attributes and building out your own UI when core will do it for you for free
Feb 16 at 10:09 comment added Tom J Nowell @DaveB if you were writing static HTML you wouldn't write a single tag then fill it with hundreds of attributes, you'd nest different tags together. It's the same with blocks. E.g. A columns block contains inidividual "column" blocks, gallery blocks contain image blocks, and list blocks contain list item blocks. They use constraints to enforce what they allow as child blocks. Take a look at the buttons and social link blocks source code. Also you don't need ot use apiFetch it'll be slowing everything down! Use the built in entity records and it'll be much faster and safer
Feb 16 at 9:54 comment added Dave B @TomJNowell - Can you give an example? I am a newbie to the world of custom blocks so any help is greatly appricated
Feb 16 at 9:53 comment added Dave B @JacobPeattie - I've edited the post that better explains
Feb 16 at 9:52 history edited Dave B CC BY-SA 4.0
better explanation of process
Feb 16 at 9:47 comment added Tom J Nowell the question you linked to is asking how to do something they shouldn't be doing, don't store multiple values in an attribute as a list, use child blocks instead!
Feb 16 at 9:29 comment added Jacob Peattie There's a lot of code here, what do you mean that the attributes array is not saving? What specifically isn't working and at what stage?
S Feb 16 at 9:18 review First questions
Feb 19 at 22:34
S Feb 16 at 9:18 history asked Dave B CC BY-SA 4.0