• Resolved charafweb

    (@charafweb)


    Hi,

    I hope you are doing well.

    I have many campaigns (~10) that share the same categories (~100 category). I want to use the wrd2cat feature (words to categories) so I can assign categories automatically to every post based on some keywords. The issue is that I have to re-enter the same 100 regex expressions for every campaign. And If I want to edit one expression I have to edit it in all campaigns.

    So, my question is : is there a way to make these “Word to category regex expressions” work globally for all campaigns ?

    Thanks

    • This topic was modified 3 years, 4 months ago by charafweb.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter charafweb

    (@charafweb)

    I think I can use the hook wpematico_pre_insert_post_callback to access to categories before inserting post. I think I can do a preg_match on title (for instance) to search for keywords and if found push a category to $args[‘post_category’] .

    I used the plugin ‘WPeMatico Custom Hooks’ to make a test like bellow. I’m tryin here to add a preexisting category called ‘Fashion’ to every new post, but it’s not working:

    function wpematico_pre_insert_post_callback($args, $campaign)
    {
    	$args['post_category'] = 'Fashion';
    	return $args;
    }

    I tried also this hook, in this way, for testing purpose:

    function wpematico_categories_after_filters_callback($categories, $item, $cfg){
    	$categories = 'Fashing'; // <== trying to add this category
    	return $categories;
    }

    But It’s not working either.

    I have a feeling that I’m missing something very simple here, but I have no clue.

    Any help would be much appreciated.

    Thanks

    • This reply was modified 3 years, 4 months ago by charafweb.
    • This reply was modified 3 years, 4 months ago by charafweb.
    Thread Starter charafweb

    (@charafweb)

    It’s the category ID that has to be pushed to arrays and not it’s name.
    Issue resolved, thank you

    • This reply was modified 3 years, 4 months ago by charafweb.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wrd2cat for all campaigns’ is closed to new replies.