Skip to main content
added 9 characters in body
Source Link
cybmeta
  • 20.6k
  • 5
  • 47
  • 56

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid]   1234/ .. /1253/ 

I tried this, the URL is like I want to be but gives me a 404 error:

function wpd_attachment_link( $link, $post_id ){
    $post = get_post( $post_id );
    return get_permalink() . 'galery'gallery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that?

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid]   1234/ .. /1253/ 

I tried this, the URL is like I want to be but gives me a 404 error:

function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return get_permalink() . 'galery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that?

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid]   1234/ .. /1253/ 

I tried this, the URL is like I want to be but gives me a 404 error:

function wpd_attachment_link( $link, $post_id ){
    $post = get_post( $post_id );
    return get_permalink() . 'gallery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that?

deleted 8 characters in body; edited title
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

Change permalink to attachment wordpress

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid] 1234/ .. /1253/

[post-permalink]/[gallery]/[postid]   1234/ .. /1253/ 

I tried this, the urlURL is like I want to be but givegives me a 404 error  :

function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return get_permalink() . 'galery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that  ?

Thank you

Change permalink to attachment wordpress

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid] 1234/ .. /1253/

I tried this, the url is like I want to be but give me 404 error  :

function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return get_permalink() . 'galery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that  ?

Thank you

Change permalink to attachment

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid]   1234/ .. /1253/ 

I tried this, the URL is like I want to be but gives me a 404 error:

function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return get_permalink() . 'galery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that?

Source Link

Change permalink to attachment wordpress

Hello i found this code and I modified a litle, but i have a problem with it.

I want the link of the attachment page to be something like this

[post-permalink]/[gallery]/[postid] 1234/ .. /1253/

I tried this, the url is like I want to be but give me 404 error :

function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return get_permalink() . 'galery/' . $post->ID ;
}
add_filter( 'attachment_link', 'wpd_attachment_link', 20, 2 );

How to do that ?

Thank you