How to update WP post's permalink programmatically based on post ID?

I have a list of WordPress post urls associated with the post IDs, and I want to update their permalink. Is it possible? If so, I would appreciate if you could share the instructions.

Thanks in advance.

Welcome to the Make community!

You’re looking to update the post “slug” field.

Does the Wordpress Update a Post module allow you to do this?

samliew – request private consultation

Join the Make Fans Discord server to chat with other makers!

2 Likes

Hey, thanks for your response! Yes, that field slug is exactly what I’m looking for. Now I’m having a new issue with Iterator. (By the way, I have already submitted a support ticket)

I have a column of Post IDs in column C, and another column of Slugs in column D in Google Sheet. I want to update WordPress post’s slug one by one. My current set up is this:

Step 1: Get Range Values from Google Sheet, including two headers: Post ID and Slug.

Step 2: Iterator. I mapped two fields from Step1 output: Post ID, and Slug.

Here’s the problem: I ran Step 1 and I can see values in the output. But I ran Iterator step, and the output is empty. Which is why my next step isn’t working.

Step 3: Update A Post in WordPress. In the Post ID and Slug fields, I pulled in the variables “Post ID” and “Slug” from the Iterator step. It’s not working because the Post ID is empty.

Did I make any mistake here? It has taken me a few hours debugging, but no luck.

Current behaviour
The Iterator step always shows empty output, although the Google Sheet step shows correct values (Post ID, and Slug) in the output.

Here are the scrn shots: as you can see, the Iterator doesn’t output any value extracted from Google Sheet.



Iterators can only iterate ARRAYS.

You cannot combine Row number and Slug variables like that because it’s a STRING.

I think you do NOT need an iterator module. Delete it.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

samliew – request private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like

Thanks for the tips. I’ve gone through them, they’re helpful, but may not help with my case. What I have is really simple ( I think). I have these two columns of data extracted from Google Sheet module.
col
How can I let Update Post from WordPress process them one by one?

This is what I have without the Iterator step as you suggested:

The mapped variables directly from G-Sheet Get Range Values don’t contain any value. But I do see values from G-Sheet output.

Now, you will need a Wordpress “Get a Post” module to get the post’s existing values, so you can map them in the “Update a Post” module.

Screenshot_2024-06-18_100646

samliew – request private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like

I think you need to delete row 1 in your spreadsheet, and make sure the Google sheet module is configured that your spreadsheet has a header row. That way when you search the spreadsheet you will get the necessary rows from the spreadsheet without the header. Alternatively when you get Range values make sure you are not including the header row in your range otherwise that header row without values will be processed as well.

2 Likes