I have a site with 1000's of products that were originally entered incorrectly. The titles have been updated, but the URL title's still have the old data. Is it possible to bulk update these entries to with either a sql query or script?

3 Answers 3


You can do a bulk update of URL Titles with SQL like:

UPDATE exp_channel_titles SET url_title=REPLACE( LOWER(title) , ' ', '-') WHERE channel_id=1

You can see URL Title is being derived from Title replacing space with dash and changing in lower case. You can have channel_id and any other condition in WHERE according to your preference.

You can have second approach by writing script using Channel Entry API like:

        $this->EE =& get_instance();

    $channel_id = 'Channel id number here';

        $entries = $this->EE->db->select('entry_id, title')->where('channel_id', $channel_id)->get('channel_titles')->result_array();
        foreach($entries as $entry)
            $data = array(
                    'title' => $entry['title'],
'channel_id' => 'channel id number'
            $this->EE->api_channel_fields->setup_entry_settings($channel_id, $data);
            $this->EE->api_channel_entries->update_entry($entry['entry_id'], $data);
  • What about replacing special characters and duplicate title's to increment correctly?
    – Siebird
    May 10, 2013 at 16:29
  • 1
    yes, this was also in my mind and my second way was to write script using Channel Entry API. It would help you. See my updated answer. May 10, 2013 at 16:48
  • Awesome, how would I initiate this script?
    – Siebird
    May 10, 2013 at 17:23
  • You can EITHER develop a small plugin and put plugin tag within a template OR just put the code within a PHP enabled template and run the template URL in browser. An extensive way would be to develop a module having action so that you can have URL like yoursite.com/?ACT=[ACTION ID] May 10, 2013 at 17:28
  • Getting a parse error: Parse error: syntax error, unexpected '}' in /var/www/vhosts/domain.com/httpdocs/system/expressionengine/libraries/Functions.php(683) : eval()'d code on line 13
    – Siebird
    May 10, 2013 at 21:22

Bhashkar's answer is great - though a quicker solution might be to install Title Master. It has an option to update the URL title for all entries in a particular channel at once - and it's also an incredibly useful add-on.


If you want the URL title to follow the same format as in the CP when creating an entry. Eg My Title is my-title then a simple PHP script could batch change these as both fields are in the same table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.