My First WP Hack

Alan Levine aka CogDog barked this April 27th, 2005 3:16 pm

I just wrote a itty bitty PHP script to deal with my 800+ imported MovableType posts- as far as my newbie eyes could see, the Permalink URLs contstructed from these were producing some 3 mile URLs because the format I used based on the post name.

On new WP entries, I have options to create a “slu”, a shorter URL name used for Permalinks. The task was to walk the database and re-write the values for postnamein the posts table to a shorter string. The script merely reads in the current postname (basically the title all converetd to lower caase with “-” replacing spaces” from the table, split it into a pHP array based on the hyphen, and if there were more than 2 “chunks, e.g. “my-really-big-long-winded-blog-post-makes-a-long-url”, it updates the row in the database with just the first two pieces.

It’s not the greatest approach, but our domain is long enough already, I hate having even longer URLs for Permalinks. You can find the the PHP script at:
http://cogdogblog.com/hacks/make-slugs.php.zip

Just ftp make-slugs.php to your wp-admin directory, and call it from the browser

Comments are closed.


Creative Commons License
This work is licensed under a Creative Commons Attribution 2.5 License
and may be patrolled by a friendly small dog (with a wagging tail)
This means you are free to use any original content published here (begs the question why)
as long as you provide linktribution.

.