how do i change wordpress default Post URL's

Discussion in 'PHP' started by tyankee, Dec 12, 2014.

  1. #1
    I think PHP is the right section but it might be htaccess.

    Here is what i need to do and i think it needs to be changed in the wordpress coding?

    i know wordpress gives you the ability to change the URL of your post but i don't want to do that. I want to take what Wordpress creates using the 'pretty permalinks' option and add 'for-sale' at the end of EVERY URL automatically every time a post is created. I would think this is easy but i can't figure it out.
     
    tyankee, Dec 12, 2014 IP
  2. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #2
    Settings->permalinks

    Then pick custom structure

    /%postname%-for-sale
    Code (markup):
    That should work
     
    Anveto, Dec 12, 2014 IP
  3. Naina S

    Naina S Active Member

    Messages:
    203
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    93
    #3
    In 'Settings' in worpdress CMS you will find a lot of thinks like changing the URL structure. Changing the starting page of your website. Whether you want to set the starting page a blog or page? etc. So do look into them.
     
    Naina S, Dec 12, 2014 IP
  4. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    #4
    Oh, and only certain types of Posts which i can identify by post_type.
    perfect... thanks..
     
    tyankee, Dec 12, 2014 IP
  5. Googl

    Googl Active Member

    Messages:
    509
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    75
    #5
    You need to filter the permalink. You could use:
    function append_string( $url, $post ) {
        if ( 'my_custom_post_type' == get_post_type( $post ) ) {
            return $url."-forsale";
        }
        return $url;
    }
    add_filter( 'post_type_link', 'append_string', 10, 2 );
    PHP:
    I haven't tried this. Here is a documentation from wordpress: http://codex.wordpress.org/Plugin_API/Filter_Reference/post_type_link
     
    Googl, Jan 5, 2015 IP
  6. hostingros

    hostingros Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #6
    Wordpress Admin Panel >> Settings >> Permalinks
    Hit on Custom Structure (Radio Button)

    /%category%/%postname%-%post_id%.html


    This should help :)
     
    hostingros, Jan 6, 2015 IP