Modify Attachment Page

I want to edit the attachment page. First I want to remove the sidebar and make the post on the center.
I tried this code both on the Edit CSS and on Theme Option > Other > Custom CSS. But it didn’t work.

.single-attachment .main-content-inner {
width: 100%;
}

.single-attachment #secondary {
display: none;
}

I also would like to know if is possible to limite or be specific on what attachment page the previous and next button go to.

I would appreciate any help :slight_smile:

Okay, so I figured some things out. The code does work but only to images that are not attached to any page. If I attach an image to a page on the media library the sidebar show up again.

The only way to limite what images the previous and next button go is attaching them to the page I want the thunbnail to show up. If there’s another way to deal with this situation I would love to know.

But to solve the problem I removed the buttons and add my own navigation on description.

Now I would like to know if I can center the image on the attachment page since all of them are on the left stead.

Hi @odisaki,

I hope you are well today and thank you for your question.

The CSS code that you have shared is working fine for me for all the attachment pages regardless the image is attached to page or not.

Could you please share me the attachment pages URLs where it’s not working so that i can troubleshoot it?

You can remove the Previous and next buttons on specific attachment pages by using the following CSS code where 760 is the attachment id which you can change with other attachment id.

.single-attachment.postid-760 #image-navigation{
  display: none;
}

Alternatively you can remove the buttons from all attachment pages and display them on specific pages using the following CSS code.

.single-attachment #image-navigation{
  display: none;
}
.single-attachment.postid-760 #image-navigation{
  display: block;
}

Best Regards,
Movin