views:

554

answers:

4

I've been looking for this all over, and simply cannot find it.

I have a blog that has no titles in its blog posts, but I'd like, for various usability reasons, to have the permalinks use the first few words from entries that do not have titles as the permalink slug.

  ie, if the post on sample.com/blog is
  Title: (no title)
  Content: Ten Easy Ways to Lose Weight

The permalink could be sample.com/blog/ten-easy-ways-to-lose-weight.

Are there any plugins that do this? For the life of me, I cannot find one. (xposted to WP support, but no one is responding)

A: 

I doubt there's anything like this already built for wordpress. To get your blog to do this, you have to write a plugin that does the following:

  • Generates the slug while checking for uniqueness should you ever start more than one entry with the same words
  • Processes URL requests to recognize slug permalinks and then updates the query step to locate the correct post in the database. This might involve a new db table of slugs (which would also help with the uniqueness issue)

In short, WP is designed to retrieve almost everything by keys, and to support slugs like this you'd have to create a new key type.

Todd Rowan
+1  A: 

You could enter in titles, and then not display them in your view template.

Marc Hughes
A: 

btw: if anything is retrieved by IDs (keys), it is technically not a permalink. so, wordpress probably fails in providing true permalinks.

ps: it's not that difficult to write an handler/dispatcher that would parse URL and takle out the unique permalink and then match it to the DB by the string (not by the key!).

something like:

$url=$_SERVER["REQUEST_URI"];
echo 'URL called: ',$url,'<br />';
$dispatchfile=$dispatcher->Dispatch($url);
if ($dispatchfile)
   {
   echo 'launching ',$dispatchfile,' inclusion<br />';
   require($dispatchfile);
   }
else
   {
   echo 'dispatcher failed to find module, will check physical file<br />';
   if (file_exists($url)) echo 'dispatcher found physical file<br />';
   else echo 'nada, throw 404!';
   }
dusoft
A: 

You can get a permalink redirect plugin from http://scott.yang.id.au/code/permalink-redirect/ Works fine with WP2.71 It takes the Title and auto-creates a slug from that so you would have to manually enter the slug you wanted for each page if you have a Blank Title.

You should be able to hack Scott's PHP file (it is one page only) to look up the page code and select a portion of it to use as a slug though.

In addition, I solve incorrect page requests using a .htaccess rewrite file to bring up the index page upon an incorrect page request.

Download a copy of my rewrite file here https://oulixes.com/htaccess_example.zip Unzip the txt file and rename as .htaccess and upload into your root directory

Hope this helps! Cheers, Billy