Skip to main content
21 events
when toggle format what by license comment
Nov 30 at 7:02 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Jul 30 at 5:08 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Mar 30 at 18:01 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Nov 30, 2023 at 2:01 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Jul 31, 2023 at 10:06 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Apr 1, 2023 at 16:03 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Dec 2, 2022 at 4:13 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Aug 2, 2022 at 11:03 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Apr 3, 2022 at 20:03 history bumped CommunityBot This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Aug 15, 2020 at 12:28 comment added Harry Tuttles I've searched CPT and you're correct, that approach is a lot easier. Thank you for steering me in that direction. I will now look how to rebuild my site with CPTs. Cheers
Aug 14, 2020 at 16:57 comment added Tom J Nowell CPT is custom post type. As for embed, it's a general english word, you would embed a youtube video in a post, the idea being that you embed the quote in the post via a block
Aug 14, 2020 at 13:20 comment added Harry Tuttles Thanks Tom. I don't know what CPT or 'an embed' are. I've found the solution written below for the benefit of others. Is this the best solution? I don't know, but it works. Isn't this needlessly complex and horrendously low-level and error prone? Doesn't this ignore every principle of abstraction, encapsulation, and elegance learned through about 7 decades of programming languages? Sure but not more than everything else in WordPress. Which as a CMS, it sucks, but for many of us, we have no other choice.
Aug 14, 2020 at 13:18 history edited Harry Tuttles
Corrected the code; added tags
Aug 14, 2020 at 13:17 answer added Harry Tuttles timeline score: 0
Aug 14, 2020 at 12:47 history edited Harry Tuttles CC BY-SA 4.0
deleted 5 characters in body
Aug 12, 2020 at 9:00 comment added Tom J Nowell For saving data into a custom table though, you'll have to build it all from scratch. Aside from a handful of functions such as dbDelta and ways to make raw queries like wpdb, WP provides nothing for custom tables, no endpoints, no UI, etc, by choosing a custom table instead of a CPT you've chosen to do everythng from scratch
Aug 12, 2020 at 8:58 comment added Tom J Nowell If your data needs to be available on other pages, then I don't think your approach makes the most sense. Wether it's a CPT or rows in a table, you need to treat it more as an embed if you're going to take that approach. Making an editable block in a post that doesn't store its data in the post is not how it's meant to work. Look at how reusable blocks work ( reusable blocks would be a better way to implement this ). As for the REST API, I don't see why it's more complex, you make an AJAX request, but instead of sending it to an archaic admin-ajax.php you send it to a pretty wp-json/... url
Aug 12, 2020 at 0:43 comment added Harry Tuttles Thanks for looking at this Tom. My blocks store quotes, names, dates, URLs, and other data. The data should be made available to other blocks in other pages. I've looked into other solutions, but keeping the data in the SQL database seems to be the least convoluted way. I'm open to other suggestions, but imho accessing the server from the blocks editor shouldn't be THAT hard.
Aug 11, 2020 at 22:43 comment added Tom J Nowell blocks shouldn't contact the REST API themselves, that's not how it's meant to work. They update a data store that represents the post, then the editor uses that to save the post. To have a block that changes a custom table when it changes is very unusual, and probably not the ideal way to do things. Can you provide some background context so we know why you're doing this and how t's meant to work? Why do you need to change the custom table? What does the block do?
Aug 11, 2020 at 19:08 review First posts
Aug 12, 2020 at 3:32
Aug 11, 2020 at 19:06 history asked Harry Tuttles CC BY-SA 4.0