Gato GraphQL Webinar Series #4 – Updating content in bulk, Automating tasks

Get 30% off Gato GraphQL (any bundle or extension)

This offer expires 13th December 2023

On this episode of WP Builds Webinars, we dive into the 4th episode of our Gato GraphQL Webinar Series… updating content in bulk, automating tasks.

In today’s webinar Leonardo showcases the practical applications of the Gato GraphQL plugin, demonstrating how GraphQL queries can streamline processes, automate tasks, and modify content on a website without the need for manual intervention.

He provides a live demonstration of using queries to replace old URLs with new ones in posts, showcasing the time-saving potential, especially for managing substantial volumes of posts or audio files.

We explore the convergence of queries with spreadsheets, discussing how this integration can revolutionise the process of managing and updating URLs for podcast files. Delving into the technical intricacies and practical usages of GraphQL queries, addressing both their inherent complexities and their capabilities for WordPress automation.

Leonardo also shares his insights on the impending launch of a groundbreaking improvement to the plugin in the new year, promising advanced automation capabilities akin to Zapier but with a more technical user experience.

The discussion paves the way for understanding the potential impact of this upcoming release on WordPress automation and its wider implications for website management.

Whether you’re a seasoned developer or an enthusiastic WordPress user looking to explore the world of GraphQL queries and automation, this episode is packed with invaluable insights from Leo.

We talk about:

  • [00:00] Demonstrating computer screen for task automation.
  • [03:58] Replace PHP code with stored GraphQL queries.
  • [08:11] Check for hooks or add developer support.
  • [11:11] Retrieves post by ID, exports data. Creates new post with mutation.
  • [16:01] Discussing automation tools such as GraphQL and Cron.
  • [19:24] Email about site information query and Markdown.
  • [20:59] Daily automation with GraphQL for data-centric tasks.
  • [27:00] Issue with code query, features for automation.
  • [29:42] Importing posts from CSV with variable mapping.
  • [32:28] Efficiency and ease in content modification.
  • [37:29] Positive outlook and potential solution for problem.
  • [40:27] Check out webinars wpbuilds.com/demos-archive.
  • [41:06] Thanks for your question! Happy holidays and goodbye.

Useful links from the show:

Gato GraphQL website

Read Full Transcript

[00:00:04] Nathan Wrigley: This episode of the WP Builds podcast is brought to you today by Omnisend, the top rated email and SMS marketing platform for WordPress. More than a hundred thousand merchants use Omnisend every day to grow their audience and sales. Ready to start building campaigns that really sell? Find out more at www.omnisend.com.

And by GoDaddy Pro, the home of managed WordPress hosting that includes free domain, SSL, and 24 7 support. Bundle that with The Hub by GoDaddy Pro to unlock more free benefits to manage multiple sites in one place, invoice clients, and get 30% of new purchases. You can find out more at go.me/wpbuilds.

Hello. Good afternoon, good morning, good evening, wherever you are in the world. Very nice to, to join you again, Leo. How's it going?

[00:01:06] Leo Losoviz: Very good. Thanks, Nathan. Nice. Nice to meet you again. Yeah.

[00:01:09] Nathan Wrigley: Just before Christmas. We're dropping in the fourth episode of the five part episode series, all about Gato, GraphQL, which is Lee's.

This is my gift. Ho. That's right. Yeah. Yeah. Oh,

[00:01:22] Leo Losoviz: I'm sorry. I'm sorry guys. This is all I can give you.

[00:01:26] Nathan Wrigley: That's okay. You've given more than enough. With your fabulous plugin, we're gonna show what it can do. Today we're gonna be talking about, updating content in bulk and automating tasks. We'll be back in the new year for the final episode.

But, for today, if you, if you're joining us live, great. Feel free to make a comment. If you want to do that. you best place to do that is to head to WP build.com/live. and over there you can use YouTube comments. You need to be logged into Google or if you click the little live. Chat widget, which is inside the video.

you can see the comments from all the platforms, if any, come in. so wp builds.com/live. And if you're in Facebook, go to that link wave video slash live slash Facebook. If you've got any questions or anything like that, please do drop them in. otherwise, should we get stuck into it? Leo, we're doing a slightly shorter one today because there's less, to say in this particular topic, but that's fine.

Yeah.

[00:02:26] Leo Losoviz: Shall I share the screen? Yeah. yes. Oh, great. So actually I need to show something. One, one of the reasons why I have less to show is because I didn't manage to finish something that I can demonstrate. I have it on, I have it on development, and I was I. Confident that it'll be ready by today.

But you know how development is. Ah, yeah. So I'm going just to show this screen from my development computer. this is all you will see, so I'm not going to even run it because actually not it, not even working, but because actually today, one of the topics was automation. And just to, explain actually I will, explain a bit.

What is the idea here? You have a graphical query. You run the query, it does something, you can update the post, you can send an email, notify your users of something, whatever it is, it's like a task, it's like a code snippet of sorts, right? That, you have the plugins, code snippets that you can answer PHP code, and then you run the task, whatever it is, it like, very useful for these very tiny tasks that you don't want to have a dedicated plugin, right?

So then what happens if you start chaining the execution of these, code snippets, right? Then you can automate tasks. You could say, for instance, when there's a new post execute this snippet, which is send an email to the user. So you can do exactly the same with, gato GraphQL. The idea will be, instead of having a code snippet with PHP code, you have a GraphQL query.

So the idea is, once again, you have a. An event happening, there's a new post, and in this case, what you do is to execute. So this is how it, will look like in the future once it is ready, right? But you'll have the list of all of the persistent queries that we have created. Basically, they're like queries that we have stored on our WebPress site.

This is once again, similar to the code snippets, plugins instead of storing. PP code, like bits of PHP code that executes something new store, a graphic query that executes a task. So I have all of this bunch here as missing links at the mandatory comments block, duplicate the post, duplicate post, and so on and so forth.

And you can, select what like. When to trigger it here based on the hook. And then you pass the parameters here. Basically the graph Q query will need, to receive the post id. And the way that I do this is by passing this, JS O. This is the variable from graph QL post id. And this is the argument that is coming from the hook.

And then it will be possible to chain different. Queries. So I will be able to say, and when this query is finished, execute another one. I dunno if I can show this, but basically I see, yeah. So then you, are, creating a chain, right? and here the, okay, the trigger.

In the moment I have only the hook, but here I will have another trigger, which basically says. this previous task, and then you execute another one. So the idea with this is, one, one example that I have in my head that I really want to implement, right? we saw one of the previous episodes to, translate con content that it connects to the, Google translate, API it translate the blog post.

Yes. And then we also saw that if possible, to synchronize content that you have another server. And you can export your, sorry, export a post to that other, WordPress site. So now we can combine them. We can say whenever Nice, whenever there is a new post first task, translated second task, export it to this other site.

So then you can have a multi-site with all the different languages and it's all automated. When you create a new post, it automatically creates the new post on the multi-site side. The translation already translated to the language. Yeah.

[00:06:40] Nathan Wrigley: That's neat. That's really neat. Yeah. and I wanted, and so each of the, if you stack them, it would wait for the previous task to finish.

There'd be some signal to say, that one's done. Okay, now move on to the next one. And then when that one's done, we move on to the next one, and so on and so forth. Oh, that's,

[00:06:59] Leo Losoviz: cool. I wanted to show you that, but,

[00:07:03] Nathan Wrigley: but I like the, just as a total aside, so this is all built in the block editor.

You're gonna create these, yeah. You're gonna create these automations in the block editor and it just, the first thing that jumps into my head is it reminds me of, Zapier or Zapier, depending on how you pronounce it. Yeah, absolutely. Absolutely, you set a trigger on the left and then what's to happen on the right?

And you can set, multiple things to happen based upon each trigger and Yeah.

[00:07:29] Leo Losoviz: Okay. I'll tell you more, I'll tell you more, Nathan. Actually, my inspiration for this was, there are these automator plugins, right? You have, and Kanye. Yep. And Kanye Automator, and That's right. Yep. And automators, you have three or even four, And I remember I was actually, on a group like WordPress group, some group on Facebook, and one person was asking. How do you get to customize that detail? when, the, like the automators you have, everything is predefined for you. So there's a task there and you need to select that task and then the options, you have to select everything.

What happens if the option that you need is not there?

[00:08:10] Nathan Wrigley: Yeah,

You gotta

[00:08:11] Leo Losoviz: build it. So you have two options. You have to check if you have a hook, and then you have to upload PHP code and it defeats the purpose. Or you have to call the developer from the plugin and add them to all support for that feature.

and, it's actually, it could be quite annoying because one of the things that you can do with this automator plugins is that you can interact with external services, right? You can post to Twitter, Facebook, whatever it is, MailChimp, whatever it is. So what happens if you are, you have predefined the, services that you want to interact, but nowadays a new service that nobody knows of, right?

If not popular, is in my country that nobody, uses. it's very tiny. And so the option is not there. What do you do? And when I read that, I was like. I can do that. So once again, the, cool thing about this is that this is a, graphical query. So let's go back to, oh, I, have to, I'll create, okay, so let's back, go back to the beginning.

Okay. This is the website. and if you go the way down, here is I play with gatto graph and testing site. So I'm going to open this and I'm going to launch a demo. This is what I'm going to use for the demo,

[00:09:27] Nathan Wrigley: and we're gonna pray it works. This time we had, issues. Yeah. On a previous one, but it look, it's looking good.

it's already

[00:09:34] Leo Losoviz: complete, otherwise going to, that's

[00:09:37] Nathan Wrigley: right. Yeah. Oh, bless him. It's a stellar service. It doesn't normally fail.

[00:09:45] Leo Losoviz: Now, somehow that day. But yeah, otherwise it's really

[00:09:51] Nathan Wrigley: good. The technology. It was because you were doing a live demo. That's how it works, Leo. That's how the universe works.

Do it a thousand times without a live demo. Perfect. Live demo.

[00:10:01] Leo Losoviz: Should stop doing demos. So only next time, Nathan, I'll just, I just have his, A PowerPoint.

Okay. okay, here we go. Here we're, yeah. So here we are. So there's a bunch of persistent queries, which are graphical queries, which are stored on the site. So here there is one that is called duplicate post. We, have already, I'm going to, show this again. we had seen this, the previous time, but, Let's do it

[00:10:34] Nathan Wrigley: again. It's good, to repeat things. Sometimes.

[00:10:38] Leo Losoviz: I'm going to duplicate, a post.

Let's just say one This is the hello world. Hello World post. Yeah. So I click here and now if you go here. Here it has the new one that have in duplicated, right? Yep. But now you can edit this, this graphical query. So here, for instance, when it is, okay, let's see how it works a tiny bit.

This is a query and what it does is to retrieve a post by id. And this is the variable that we pass here. Post ID one. So it is basically selecting the post. One, which is a one world, and it fetches all of this data that I, that indicate ID slack date status. That is everything that is showing here, the author.

And I'm exporting this data, the categories, and I'm exporting this data, the content excerpt, feature image tags, and the tile, and I'm exporting this data. And then I grab this, the tile, the tag id, the feature image id, and I create a new post with, this is with a mutation, right? So I export the data from any post and I create a new post.

it's quite simple, and they know possibility of anything going wrong in a way, this is not like PHP that, you can create a, an error and then you have a, 500 error. Then the website doesn't load anymore. If it fails, if I do something wrong here, for instance, let's do this. This doesn't make it, oh, actually no, sorry.

This will just fail if I do this. It just says incorrect sentence, but nothing fails. Yeah. Yeah. So here we can customize this. So for instance, one thing that I can do is instead of draft, let's just do it or whatever pending. Yeah.

[00:12:39] Nathan Wrigley: Okay. So now it'll create, but it'll be set to pending. Got it.

[00:12:45] Leo Losoviz: And now you can, it's, or I can modify the tile, so then I can say, attach or append another string.

So something

[00:12:58] Nathan Wrigley: else? Yeah. Copied post,

[00:13:01] Leo Losoviz: duplicate. Yeah. Yeah.

Now, oh, what do I do? Oh, there you

[00:13:10] Nathan Wrigley: go. There duplicate.

[00:13:12] Leo Losoviz: Ah, what am I doing?

There you go. So I'm, demonstrated that nothing can go wrong, basically. no,

[00:13:25] Nathan Wrigley: it didn't go wrong. It was user, error. That's fine. There it is.

[00:13:32] Leo Losoviz: Yeah. So what, so then we were talking at the, automator plugins. What happens if you need to send a, pinging to a new service in town? No problem. You edit the GraphQL query and then you add the, URL of the new service, and then you pass the whatever it is that you need to pass under the body or as a, as, a, parameter.

Yeah. And you got it running. actually we, so you

[00:13:57] Nathan Wrigley: can really build anything that you, you, your imagination is the limit. You don't need to contact the developer. You just need to amend the query.

[00:14:05] Leo Losoviz: As long as the plugin supports that. Yeah. Yeah. We, were talking about this on, day one, I think, how much support that is, oh no, sorry.

This was on the podcast. we, on the podcast, on, the audio podcast that we did. Yeah. Yep. I'll mentioning, I, don't have support for a CF yet.

[00:14:27] Nathan Wrigley: But you will. maybe at

[00:14:28] Leo Losoviz: some point, maybe at some point, who knows. So if you need that, and people ask me, so I need that, and I'm like, sorry, you had to wait.

So the thing is, as long you have a field, like just now. Okay, let's, go back to, the query. So this field called Post, I had to program that this, the gato graphical plugin has already, is already, resolving the post. That's why it works, but you cannot do a product. E-commerce. Okay. Yep.

[00:15:00] Nathan Wrigley: You'd have to do that yourself. Write that yourself

[00:15:02] Leo Losoviz: somewhere. So yeah, if people want to do it themselves, they can. They, okay, so this is supposed to be the, next, episode, but no, I just mentioned this. I'm not going to go. Okay. So here, there is a, an extension starter.

Basically, it's a GitHub project that. It's a template that allows you to create, extensions for gato GraphQL. Got it.

[00:15:31] Nathan Wrigley: Okay. Wow. Alright. Yeah,

[00:15:33] Leo Losoviz: we'll, see this actually next step because I think it's quite cool. Yeah. But I don't want to get, yeah. Get lost in the weeds there. Okay. Yeah. okay, then we were on the automation thing.

If something doesn't, is not there, you just adjust the graphic query and then you're, good to go.

[00:15:54] Nathan Wrigley: Sorry, I'm having a coughing fit over here. I'm just putting myself on mute for a moment.

[00:16:01] Leo Losoviz: Okay. Okay. and then we have, so we have all of these, oh, so then there goes the part of automation that is the first part, which is to, create an automator of, plugin that, you can actually do with GraphQL. The second thing that you can do is to use Crohn Theron. Oh, okay. Yes. I'm going to show you the documentation on the website for this, and maybe we can do it, but it will not work, because this, this, testing site that not send emails.

Okay. Yeah. And I, because basically, what do you do with, chron, right? say you have to do a task every 24 hours. So one example is, okay, send a summary of the number of comments you have got in the site, whatever. we will actually do everything, even though we'll not, I will not show you the final email.

[00:17:01] Nathan Wrigley: That won't the final email. Yeah. Yeah. But trust us, it'll work.

[00:17:09] Leo Losoviz: yeah. So we, in, in the site here, there is a link called tutorial. And here it says, sending a daily summary of activity. So here it gives me one, graph query. I'll just copy this. I'll create a persisted query with this. Okay.

[00:17:30] Nathan Wrigley: And we went into those on a previous episode.

These are things that you can just reuse over and over again. Yes.

[00:17:35] Leo Losoviz: Yeah. So we add a new graphical proceed query. I just paste this, Let's just also copy the tile.

Oh, daily starts by email. Number of comments. I want to do copy paste, so I'll just call it that. Okay. Daily starts by what?

[00:17:59] Nathan Wrigley: email.

[00:18:00] Leo Losoviz: Number of comments. Number of comments. Oh, by email. By email. Number of comments. Number of comments. Okay. Something like this. Yeah. Yeah. schema confirmation. I, know I need the nest mutation, so I will publish this.

So having this, having the, slag, then I can go to, to WP Chrome like this with PHP code. And basically what they will do is, you, say to, you're scheduling the event, starting from to now. You execute it daily and you execute this. hook the name and with this information daily starts by email, number of comments, so that this is the slag of the query.

Yep. Yeah. And they, and then you pass the, variables that you need that the, that the graphical query requires. It has the two variables. So then you provide here the information. And we can also do it, we can actually do it. With WP Control, we can install it now. Oh, you can?

Oh, you can just trust me. I can just show you this. Yeah,

[00:19:10] Nathan Wrigley: it's okay. it's up to you, but you Yeah, I,

[00:19:13] Leo Losoviz: trust you. Yeah, no, because I, cannot Yeah, because the email is not being sent. Yeah, exactly. oh. Actually, look, I'll show you this. If I run this,

[00:19:22] Nathan Wrigley: you can see the, you can see what's output right there.

[00:19:24] Leo Losoviz: Yeah. Oh, I haven't, I need to say the two. Two, Nathan, but you'll not get this email. No. So I sent, I supposedly send this. So here what, there we go. What this queries is doing is getting information from the site, the time today, time yesterday, and then it calculates the comments added in the last 24 hours in the last one year since beginning of the month and seeing beginning of this year.

And then I use Markdown to compose the content of the email and this will be transformed to HTML. This is the, response.

[00:20:07] Nathan Wrigley: Yeah, I see it. There it is.

[00:20:09] Leo Losoviz: Yes. And it will then send an email. But this is the thing that is not working. Yeah, Just failure because, yeah, because this is a testing site with, instead WP cannot send emails.

but in anyways, this send email is connected to the WP mail function. Yeah, that's right. Yeah. Yeah. So it just works out of the box normally. So then. When you add this information in WP chron, it will basically send an email every day with whatever it is that the, query is producing, right?

Like the, query producing the, number of comments on the site. And that's what it sends you by email.

[00:20:56] Nathan Wrigley: So,

it's another way of getting it to, getting it to be triggered.

[00:20:59] Leo Losoviz: Yeah. Yeah. this is, automation. What do you need to do? What do you need to run, right? every day you need to do something.

If it is possible to do it with GraphQL, if it is data centric, that is something that depends on data, like post information, users information, number of new users that you got, revenue that you got, or yeah, products that you have sold on the day or on the last two weeks, on the last month. And you don't want to do something with this, or you want to pinging, maybe you want at the end of the day pinging another site with some content that you have on your site for This this is just perfect.

[00:21:37] Nathan Wrigley: Nice. But when you, obviously hoped to have that built, at some point, but I guess you're waiting until the new year now before

[00:21:46] Leo Losoviz: you ship that. Yeah, And actually, okay, I think I told you the, previous time my plugin got approved for the direct call. Oh.

But I have not been working on this yet because I still need to do a few things before I can launch it. And I was thinking I need to finish this before the, this episode today, so I'll working on this. And at some point I, I was like, I'm not going to finish it. I'm not Yeah, you knew. So since I haven't finished it anyway.

Now this is going to take the backseat and I will work now on launching the plugin on the, yeah, the plugin. Okay. Okay. May, yeah. I think by beginning of next year, that will be my. My new Year wish, like a good way to start the year with the plugin

[00:22:34] Nathan Wrigley: out there. That's great. That's perfect. So we know it's coming and I think given your track record, we know it'll, we know it'll work and it'll do everything, and we've got some kind of intuition of how it'll work and everything.

So it's gonna be like a Zapier type experience. You, plug things into the Gutenberg block editor and. Set triggers, set tasks to be performed based upon those triggers. And you're off to the races. And as, as with everything inside your plugin, really your, the only limitation is what you can conceive.

Yeah. You've built so much stuff into there. So the example there that you just gave, sending an email is, like 1000000000000th of what would be possible.

[00:23:12] Leo Losoviz: Yeah. you just need to get again, even though I don't, want to create false expectations. They have the functionality from Zapier, but it doesn't have the user.

Experience. All of those systems are, yeah, nice. They're easy to use, right? You drag and drop, select this mining, not like that. Mining more, it's a bit more technical. And even talking about GraphQL, it's a bit of, something that people are a bit scared about, because it's a new domain, right? Yeah.

I, completely understand. So I'm not trying to create, false expectations. Basically what this is it like Zapier, but for developers of sort? Yeah,

[00:23:51] Nathan Wrigley: that's right. that's a really good way of thinking about it, isn't it? Is that you need a certain technical level of expertise in order to make it work.

But it feels to me that you don't need to be that technical once you've got your head around how the syntax works. Yeah. You just have to repeat. Of that over and over again, but yeah. Bringing in, yes.

[00:24:09] Leo Losoviz: And, let me, since we're talking about this, let me show you something that I have done That this is actually new. I create a new section called the Queries Library. Oh, nice. Yes. so what, is this? This is, I, right now there are 50, but to be honest, I have 20 or 25 more that I need to upload, and then I have ideas for 50 more easy. Yeah. Yeah. So this is, The graphical query that solves a given problem.

for instance, these ones is called add a mandatory comments block to a post. Oh, let's do this one. Actually. this is going to be fun. this actually also I could have shown you with automation, but unfortunately, as I said, I don't have it ready yet, but let's do it manually. So you go to this query library, and here it says, what is the problem?

You want to add a mandatory comments block to post. So say that you have, the, comments. Now using Gutenberg are also a block. Yeah. What happens if you forget to add it? Yeah.

[00:25:13] Nathan Wrigley: So this is gonna force it to ha you can't publish it until you've put the block in, or it's gonna add the block whether you like it or not.

[00:25:20] Leo Losoviz: Here we go. So what this is going to do when I run it is I will check. Okay, let's, see the where any bit, yeah. it selects, It checks, if the comment is, the block is, sorry, is the post that we indicate, has the comments, ending tag, which means doesn, he have the comments block or

not.

[00:25:42] Nathan Wrigley: Oh, that's, a neat way of doing it.

That's interesting. Yeah. Okay.

[00:25:46] Leo Losoviz: So based on that, I can tell if the Post has the block or if he doesn't have it, if it, if it has it. Sorry. If it doesn't have it doesn't have it. Yeah, Skip if it has it already, then you skip this. It doesn't do this otherwise, what it does is it, fetches the content of the post and it append.

Oh,

[00:26:14] Nathan Wrigley: right, So it repeats the entire post and then adds the block in it afterwards. Exactly.

[00:26:21] Leo Losoviz: Neat. And then you update it. So let's actually run this so it'll bring all

[00:26:28] Nathan Wrigley: of your other blocks that you might happen to have dropped into if you've got a YouTube. 'cause it's just taken the raw content of everything.

That was anything.

[00:26:35] Leo Losoviz: Anything, Yeah. And, actually this is both a feature and a bug. look at this. This is not nice in a way that you have to input all of this, all of those, yeah. In the query. Why is it not nice? Because what happens if the block in the future is updated? Yeah. like WordPress score, they decide, to modify it.

And then this code is not valid anymore. Then you're stuck with this code in the query. so this, that's why I call this a bug, but I. Two things. First is a feature, because as I was mentioning, the same with automation. You have absolute control on what you want to add and how this is just pure code, pure content that you append you can do.

Also search and replace. one of the other, persistent queries that I had there is that you can add a block for a call to action, like a call to action block for some campaign like Black Friday, and you can insert it in the middle of the post. Or maybe after the third paragraph, what I can do is I can count the blocks and I say, I identify the third one and then I insert, yeah.

Yeah. And then I add anything else I can that came after,

[00:27:48] Nathan Wrigley: perfect for putting ads in or something like that. Yeah.

[00:27:50] Leo Losoviz: Yes. Yeah. Perfect. For, like a, campaign that is like maybe one week, two weeks. Yeah. And then I also give the query, I think it should be around here, somewhere there. But CTA, it is one of these, yeah, it's okay.

And then the query to, and then the query to remove it after the campaign once again. And this in bulk, you give the name of the block and it goes through the content. And when it can identify the beginning and the end tag for that block name. It just removes that block.

[00:28:24] Nathan Wrigley: Oh, of course. Because it's not inserting it dynamically.

It's rewriting the post. So I get it. Okay. So you have to take them out manually as well? Yes. Or in an automatic manual kinda way.

[00:28:34] Leo Losoviz: Yeah. Yeah. And then concerning this ugly call, and you can see, I'm very honest, I'm talking to you as a user myself. when I do the things I like, I don't want to have to use this.

What I'm going to do that I also couldn't finish on time. I will do it like soon. I'm going to create a custom post type. Called content template that you have basically blocks that you need to, like in this case, like the comments block, so then you can fetch the content inside that CPT. Okay.

I'm,

[00:29:09] Nathan Wrigley: I think I'm, no, I think I understand. So you are gonna, it is like you are gonna put in a range of the blocks that you typically use, and you know that the code for those is gonna be consistent in the future because you made it so you

[00:29:21] Leo Losoviz: can drag it in from there. It's the, yeah. So then if that, if the block gets updated, it gets updated also on the right.

On the post. Yep. And because I'm dynamically fetching the content from that post with a new content post type, then it will be always up to date, then different doesn't happen

[00:29:37] Nathan Wrigley: anymore. So it's a bit like a PHP template, but built inside the block editor. Yes. Yeah. Okay.

[00:29:42] Leo Losoviz: Okay. Actually, the, other use case that is the one that I, was really thinking of, actually there are two.

One is to import posts. So I have the functionality, is also one of these import posts from CSV. here I have an, an Excel file and it re, it retrieves the tile, the excerpt, the content, and the author. But what happens if you have a, an Excel file that the columns are not mapped. One-to-one, it like you have the content that is scatter among different columns. You have an image, another image, one, image two, image three, and then you have to have one after the other, right?

Then with this content post type, you'll have the, final post as it will look like with variables. Image one, image two, image three. Got it. Yeah. Then I retrieve this content and I do a search and replace where it says Image one. Insert this URL from the from the Excel file versus image two, insert this other UL and then save the post.

Got it. So yeah, so all of this is all, it's complicated. All of this is all working good on. Lovely. Yeah. So let's, go back to this.

[00:31:00] Nathan Wrigley: Where were we? Yeah, that was it. add the comments block to the post.

[00:31:05] Leo Losoviz: Yeah. So we will add a,

[00:31:07] Nathan Wrigley: add a new query, assisted query. Call it something. Chuck the query in.

[00:31:15] Leo Losoviz: Here we go. this one, I think it needs next mutations. Okay. Publish it. Okay. the, let's open once again. Hello World. Here it is. so this one doesn't have the Yep. Comments block, right? Yep. So now we run that post ID one, one. Run it. I update here and now it has

[00:31:54] Nathan Wrigley: the, no kidding. Look at that.

That's great. So you could do that with any number of posts. You could just write, go through the entire yes. Roster of your a hundred, 200 posts, whatever you've got on your website, and it'll do the same thing over and

[00:32:07] Leo Losoviz: over again. Got it. And this, once again, you can automate it. So the idea is.

[00:32:11] Nathan Wrigley: Yes, of course.

Yeah. Every like 25th of December, take the Christmas ads away. Yeah,

[00:32:17] Leo Losoviz: yeah. No, what I'm thinking like this particular use case, right when you hit publish and you forgot that mandatory block, then this guy can insert it for you. Yep.

[00:32:28] Nathan Wrigley: That's, really cool. obviously you've just shown a, an example, which you know, you may or may not want, but imagine the possibilities of being able to insert that you, modify content that you've already got without having to go through it one at a time.

Yeah, absolutely. Over and over again. Oh, I've got a really interesting use for that actually, because. I'm currently thinking about swapping my podcast, service that I host my podcast with, and I've got about 618 audio files. And I need to go through every post and substitute the URL of the audio file, 618 times.

[00:33:08] Leo Losoviz: I, I, got you covered. Exactly.

[00:33:11] Nathan Wrigley: Yeah. so I would do exactly this. I'd go and find the post I would then have to retrieve, yeah, I'd have to go in, locate the block that was in use, and then substitute out the, MP three file for the new MP three file and six, yeah, that could save me a lot of time.

Nice.

[00:33:32] Leo Losoviz: Yeah. So here you have this, replace the old domain with a new domain. Oh, so what this one does is we can actually run this one.

[00:33:41] Nathan Wrigley: that's probably not what I'm after,

[00:33:43] Leo Losoviz: but it's okay. No, but yeah, no, but what you want is to replace Oh, it is. No, you're right. Yeah. You want to replace one URL? The, examples that I have, if we domain, but I could actually do that one.

The, one. Oh,

[00:33:56] Nathan Wrigley: cause 'cause the URLs won't map in any way, shape, or form. They're just, it says, I don't know, podcast host one.com/loads of rubbish mp3 and then the other one would be,

[00:34:08] Leo Losoviz: yeah. Yeah. Not exactly the same query, but it's similar. Similar. I have another one here called Replace an Old Post Slack with a new post sl.

So what this does is, when I created this query, you have Hello Wall now it's called Buy, buy Mars, and it creates a U, it creates a URL here it, it takes the URL from the database. It appends the slag to the URL and so basically it's calculating what is the old uur L and the new URL, and then you that this part you don't need.

Okay. But then you have the mutation replace all with new UR Ls in post. So you select all the posts which contain the old post URL. So in, in your case, it will be the URL for the audio. the final Yeah. Yeah. The dot

[00:35:02] Nathan Wrigley: MP3 file. Yep. Yep.

[00:35:03] Leo Losoviz: Yeah. And then you get the content and you replace the all URL with the new RL and you store and you save it again.

and you can do this also passing, a dictionary with a lot of different variables. And then it does one by one, but one, like that's all of them, right? Like you can have. I have another recipe for that, but, yeah, basically it's how it is actually. we can see that a tiny bit. Let's go back here, press the queries.

replace,

okay, RegX, let's do this one. RegX replace strings in post. So we can do a search. What do we want to search? let's make it easy here. Hello world. But maybe

we don't, we do this. Okay.

[00:36:08] Nathan Wrigley: Yeah.

[00:36:09] Leo Losoviz: Oh, that will not work. Here that replace wheat, by, by,

[00:36:15] Nathan Wrigley: by, Mars. Mars. so anything that starts, hello. And then a letter of the alphabet or will be replaced by Byebye Mars. So we are hoping that hello world gets found. Okay. So

[00:36:30] Leo Losoviz: let's, if it went fine, this killer one, there's various

[00:36:32] Nathan Wrigley: places we'll be able to see it there.

Perfect. Yeah. Look at that. That one. The treat? Yeah. Yeah. Okay.

[00:36:38] Leo Losoviz: I see it. Oh, and actually, yeah, so these ones are not published, but let's see. Actually,

[00:36:49] Nathan Wrigley: oh, that's interesting. Because they weren't published. It didn't,

[00:36:52] Leo Losoviz: okay. Yeah, because I'm not selecting them. Yeah. oh. What? To select them here. Yeah.

[00:37:00] Nathan Wrigley: Where would you, where would that be?

[00:37:02] Leo Losoviz: Filter. Status. Any, any there? I think,

[00:37:09] Nathan Wrigley: if I do this, see if it works. If it doesn't work, it's no big deal. We get the idea. it's looking for published things only on the outset, and that's a good idea. Or maybe it's there.

Okay. Let's try it. Hands, fingers crossed. Let's see what happens. It's doing things, it's thinking it's not failed. Yay. Look at that. That's so great. Okay, so in, in my, example, it really does look like that your solution might be able to help me out there a lot. I'd be wanting to probably chuck it from a spreadsheet as well, so that it was, when you said spreadsheet, that my intuition jumped in because I was thinking I can probably download the new URLs and the old URLs onto a spreadsheet.

Because I can't think of any other way. The podcast company that hosts those files would, allow me to get to them. So it feels like a spreadsheet would be the best way to do that. And then go from there. All right. see, Leo, I've found a use for it. And you said there'd only be 10 minutes of content in here.

We're on minute 40 already. I'm,

[00:38:19] Leo Losoviz: I'm talking, I'm talking more than I'll do otherwise, to be honest. I'm,

[00:38:23] Nathan Wrigley: I'm blah, blah, blah, blah. No, it's great. It's great. Are you, do you feel like you've, done that subject justice? Is there more you want to add or

[00:38:30] Leo Losoviz: do we, no, I think this is actually quite good.

I felt a bit bad that I couldn't show the automation

[00:38:36] Nathan Wrigley: thing. No, we got the idea. We understand. Yeah, I think, any, anybody, looking at that will get the idea that in the new year, in 2024, at some point you'll have a Zapier like developer experience where you'll be able to set all of those bits and pieces up.

Okay. If that's the case, we will, we'll knock it on the head. We'll stop sharing the screen and Leo, thanks for joining us again. We'll be back in the new year. I can't remember off the top of my head. I think it might be the 10th of. March, sorry, 10th of January, something like that. for the fifth and final episode of, of the GraphQL series, gto, GraphQL.

And as Leo suggested, he's gonna be extending, what the GraphQL schema is able to do. So we will see there. Oh. Quickly though, ATFA has just raised a question. Do you mind answering that? Yeah, sure. Okay. Let's put it up there. he says, can I ask a question? not to undermine anything you are showing us, it's all great, but any benefit using this over something like WP Query or is this a random example?

[00:39:37] Leo Losoviz: Oh, WP Query, but WP Query is code, right? you need to, I. You have to deploy PHP code, you have to code it on your plugin or, a theme. These, you don't, you go to the, WP admin and you create a query on the spot and, then you publish it. So they know need to actually, create an any code.

So that is one thing. So it is way more convenient. In five minutes, you can have your task going and, the other thing is no. Clearly what, what my plugin does is to call WP Query on the backend. So I'm not adding anything, anything new. all I'm doing is adding another layer to be able to interact with WP Query, from the client.

From WP Admin.

[00:40:27] Nathan Wrigley: I don't know, Atif, if you, if you managed to see any of the previous episodes, but we, I'll, if you go to now, let me think, let me make sure this is true. Let's have a quick look. Webinars. I'm just trying to find the bits and pieces. Yeah, if you go, here, wp builds.com/demos archive modeled in with a variety of different webinars from different people will be the.

Previous three episodes, that I did with Leo and, Right. Probably go for episode one and you'll be able to see how the bits and pieces are all built up. And that may give you more of a, more of an intuition, as to how it works. But thanks, for your question anyway. Appreciate it.

Okay. if that's the case, I'll just wish you, Leo, a happy. New Year and Christmas. If that's your thing, if you do that, if not, I will just say see you later and I'll, I'll see you in the new year. Thanks so much. Oh, quickly, he says he hasn't seen the episodes, just saw this and jumped. Yeah, check it out and you'll probably get a real understanding of how that works.

Leo, for 2023, thanks for joining me so many times and I will see you in 2024.

[00:41:40] Leo Losoviz: Yeah, thanks so much and have Merry Christmas. Happy new Year.

[00:41:43] Nathan Wrigley: Thank you so much.

Please leave a comment…


Discover more from WP Builds

Subscribe to get the latest posts to your email.

Filter Deals

Filter Deals

Category

Category
  • Plugin (4)
  • WordPress (4)
  • eCommerce (2)
  • Lifetime Deal (2)
  • Other (2)
  • Security (2)
  • Design (1)
  • Hosting (1)
  • Training (1)

% discounted

% discounted

Filter Deals

Filter Deals

Category

Category
  • WordPress (41)
  • Plugin (35)
  • Admin (31)
  • Content (20)
  • Design (12)
  • Blocks (6)
  • Maintenance (6)
  • Security (5)
  • Hosting (4)
  • Theme (3)
  • WooCommerce (3)
  • SaaS app (2)
  • Lifetime Deal (1)
  • Not WordPress (1)
  • Training (1)

% discounted

% discounted

SUBSCRIBE TO OUR

NEWSLETTER

WP Builds WordPress Podcast

THANKS.

PLEASE CHECK YOUR EMAIL TO CONFIRM YOUR SUBSCRIPTION.

WP Builds WordPress Podcast