WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post slug customization (15 posts)

  1. navis
    Member
    Posted 7 years ago #

    Hi,

    I wanted to make a post with the following url: http://myblog.com/2007/08/hello---world/ so I edited the post slug to hello---world but when I post it always rename it to hello-world without the additional --

    Is there a way to fix that? Thanks in advance.

  2. Bodhipaksa
    Member
    Posted 7 years ago #

    Seems like an odd thing to do, but have you tried using the html entities rather than straight hyphens?

    It's &#45 ; (without the space before the semicolon).

  3. navis
    Member
    Posted 7 years ago #

    I tried to modify one of my post slug like this: unique&#45 ;&#45 ;&#45 ;book (without the spaces)and the new url was "uniquebook". I'm not sure if that's what you mean but it didn't work that way.

  4. navis
    Member
    Posted 7 years ago #

    Can I edit a php file to change the way the post slug is written? Anyone know which file is that?

  5. Bodhipaksa
    Member
    Posted 7 years ago #

    May I ask why you're trying to do this? This isn't an implied criticism, it's just that sometimes there are other strategies to achieve a certain goal.

  6. navis
    Member
    Posted 7 years ago #

    I have a blog and it uses a blog script that you can not import into wordpress. I have more than 1000 posts there and some url's are written like: http://myblog.com/like---this/

    I worked really hard to have each url posted on other sites and that's why I can't change their name at all.

  7. Bodhipaksa
    Member
    Posted 7 years ago #

    If only some of the URLs are written like that then it's very feasible put 301 redirects in your htaccess file and people (and your pagerank) will be seamlessly redirected to the new pages. Actually it would be feasible to do this even if all 1000 posts were like that, but it would be more work!

  8. navis
    Member
    Posted 7 years ago #

    Thanks man. I didn't know that was possible, so, for a url like http://myblog.com/07/2007/like---this.html the syntax should be something like the following?

    redirect /07/2007/like---this.html http://myblog.com/newdironlyone/like-this.html

    ?

    Thanks again.

  9. Bodhipaksa
    Member
    Posted 7 years ago #

    Yes, but use RedirectPermanent instead of just redirect. Google needs to know that the page has permanently and not just temporarily moved.

    And just one space between the old and new urls (you may have done that in your example -- it's hard to tell

    This is a much better solution than hacking the core files, which causes problems every time you upgrade WP!

  10. navis
    Member
    Posted 7 years ago #

    Thanks a lot. I found out which php file I'd have to edit but your suggestion is better indeed.

  11. Dgold
    Member
    Posted 7 years ago #

    Nifty solution

    I didn't know how to set up a Redirect anyway, just learned something from that

  12. Bodhipaksa
    Member
    Posted 7 years ago #

    When I started switching a static site to wordpress I tried to find ways to recreate all the old URLs, down to recreating the .html extensions. Unfortunately with Pages this involved hacking the core files, so with some nervousness I went for having an .htaccess file with about 600 redirects. It worked like a dream and traffic actually increased.

  13. navis
    Member
    Posted 7 years ago #

    Hey dude, What else I should put in my htaccess to even install wordpress? I just put the redirects but i can't install the script, getting a internal error because of that.

  14. Bodhipaksa
    Member
    Posted 7 years ago #

    You may have to hit the "update permalinks" button in your permalinks options if you've overwritten the existing htaccess file. Or maybe you need to create a new page. I know squat about that kind of stuff apart from adding a few redirects.

    For the record, what I did in my case was copy and rename the htaccess file on the server, download it, add my redirects, rename it to .htaccess again, and upload it by ftp. That preserved all the WordPress htaccess stuff.

    Everything worked just fine, except for one time I'm missed a space in a redirect rule and the whole site 500'd. That was a scary moment.

  15. aio
    Member
    Posted 6 years ago #

    For those of you looking to edit the main WP code (like I was) to get it to work the way YOU want it:

    (wp 2.3.2) Look at file wp-includes\taxonomy.php

    And mod this:

    function wp_unique_term_slug

Topic Closed

This topic has been closed to new replies.

About this Topic