Request for conditions for "category" in the Wordpress Piece

I have 7 different categories I want to be able to post to, based on what category I have written in a Google Sheet.

Now I solve this by using BRANCH to sort between 7 different Wordpress pieces, where the only difference between these pieces is which category I have chosen.

It would be so much nicer if I could just add conditions inside the WP piece:
If variable A contains “Funny”, then use category “Fun stuff”
if variable A contains “Cups”, then use category “Kitchen”
if variable A contains “Tax”, then use category “Business”

etc.

This may not sound like much, but when building out flows for as many sites as I do all the numbers adds up. :sweat_smile:

That would make the Flow diagram so much easier to build, probably use less data power/ memory , and also quicker :slight_smile:

if it is just only the category, best thing atm would be a code step:

export const code = async (inputs) => {
    if(inputs.text?.contains("Funny"))
    {
        return "Fun stuff"
    }
    else if (inputs.text?.contains("Cups"))
    {
        return "Cups";
    }
    else if (inputs.text?.contains("Tax"))
    {
        return "Business";
    }
    //write more conditions here
    return undefined
};

1 Like

@Abdul , thank you.
How do I get for instance value “B” from a Google Sheet into this script?

And how can I use the result from this code step into a Wordpress piece?

I have programmed a tiny bit in PHP and Javascript before, but am depended on good documentation and/ or examples. :sweat_smile:

Like this

1 Like

Hello, well, I think I have the same problem, I have a flow, I use Googlesheet to generate articles, it works fine, but I need to add a category automatically, that is, from the Google cell I get what category to post.
If I do it by code, how do I link later with WordPress, because in the WordPress module in category I only see the list that is on my website, I do not have the option to add code.
can you help me @Abdul @Bram

Hi @cindyC Cindy!

You have to use the (X) on the top right of the input field to use dynamic values. Please keep in mind that you have to add the category ID’s which are the numbers not the name. Also when using multiple categories you have to use the following formatting ‘15, 16, 17’ like that.

Hope this helps, in case you need further help please let me know.

Kr Bram

yeah, it’s work
thank you

You are welcome!!!