Forums

Adjust Permalink Structure For Attachments (2 posts)

  1. bluntrizzle
    Member
    Posted 2 years ago #

    Hi there. I want to be able to rewrite (if possible) the base name for an attachement page for a post.

    Here is an example:-

    http://www.domain.com/photos/36/summer-vactation/attachment/beach-03/

    http://www.domain.com/photos/36/summer-vactation/gallery/beach-03/

    I want to change the attachment part to another word, rather than having the default way with "attachment"

    I've tried looking through the rewrite.php file but it does not make sense.

    I have managed to change the link structure in the link-template.php file to:-

    if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
    $name = 'gallery/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker

    This doesn't work when the link is launched, it just 404s. Do I need to edit the htaccess file for it to over ride this?

    I am not much of a programmer, so your help would be appreciated.

    Thanks in advance.

  2. bluntrizzle
    Member
    Posted 2 years ago #

    I've searched through the codex and found this example to add in an extra line for htaccess:-

    RewriteRule ^post/([0-9]+)?/?([0-9]+)?/?$ /index.php?p=$1&page=$2 [QSA]

    http://codex.wordpress.org/Using_Permalinks#Long_Permalinks

    Could I possibly do something more similar where I would have it structured like this:-

    domain.com/%category%/%post_id%/%postname%/gallery/%image_name%/

    There doesn't seem to be a setting for this in the WordPress admin so I'm guessing this will have to be either an easy hack replacing a certain line of code in the wp-includes folder or just adding another line in the htaccess.

    Hope you guys can help, thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic