WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Interesting permalinks issue (15 posts)

  1. ryansigg
    Member
    Posted 2 years ago #

    Here's something strange going on with our permalinks settings. When set to default, everything is fine... Everything still seems to work fine with a custom/preset permalink setting, except for pages which have an image attachment in them. These pages seem to use the attachment template instead of the page template, and only show the attached image and none of the text.

    This problem seems not to be related to the theme as it occurs even in the TwentyTen theme... Neither is it related to any plugins.

    Here's an example of a page where this is occurring (pardon the shortlink): http://bit.ly/vOmlLF

    Ideas?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Yes - that's how many attachment template files work. If that's not what you want, you'll need to start editing that theme file.

  3. ryansigg
    Member
    Posted 2 years ago #

    Wait, so the attachment template overrides the page template, even when it's a specific page template (not the generic one) that's being called?
    I've never had this happen before...

    That doesn't sound right. Perhaps, I should have been clearer, the pages are not set to use the attachment template, they just display using that template, apparently.
    The pages in question are using a custom page template (again, not even page.php), but that doesn't seem to matter, even in the TwentyTen theme.

    Also, I should add: the theme in question doesn't even have an attachment template, in either the parent or child theme.

    What am I missing here?

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    so the attachment template overrides the page template, even when it's a specific page template (not the generic one) that's being called?

    Yes. If you select "Post page" for the Link URL when inserting an image, the attachment template file will be used to display the attachment at that link. See Theme Development for an overview of the template hierarchy.

  5. ryansigg
    Member
    Posted 2 years ago #

    Sorry, but I'm not talking about displaying the attachment file. I'm talking about displaying the page that the attachment is attached to.

  6. ryansigg
    Member
    Posted 2 years ago #

    With all due respect (your posts, esmi, have helped me greatly throughout the years) you seem to think I'm attempting to view an attachment file, which is not the case.
    There is nothing on the Codex page you referred to that tells me why an attachment template would be used when trying to view a page.

    So, pardon me for repeating myself, but I'm only trying to clarify: that link above is to a page, in the most conventional WordPress sense of that word. The page is set, under 'Page Attributes', to use a specific page template. When visiting that page, instead of seeing the page content displayed with that template, or even the page.php template, the attachment is displayed as if viewing the attachment file.

    I understand the template hierarchy and don't know how the attachment template would "naturally" be shown instead of the page template when showing a page.

  7. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Try using the default page template to rule out issues in your custom template.

  8. ryansigg
    Member
    Posted 2 years ago #

    I've already done this; it's currently set to the default template.

    And as I said previously, this behavior persists even when using the TwentyTen theme.

    Also, here's a page on a different site with the same theme where pages that have attachments in them are working as expected: http://bit.ly/vS41LE

  9. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    What is in your .htaccess file?

  10. ryansigg
    Member
    Posted 2 years ago #

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
  11. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Nothing obviously problematic in there. Have you spoken to your hosts about this? It could be a server-related problem.

  12. ryansigg
    Member
    Posted 2 years ago #

    That was my next step, though the host is GoDaddy, and I haven't had good experiences working with them in the past.

    Do you think the permalink settings are breaking a path somewhere? It's simply weird to me that a template issue could be related to permalinks; I can't fathom how these are connected.

    At the very least, it seems strange that if there is an issue with the permalinks setting, there wouldn't be more problems (then again maybe I just haven't caught them yet).

  13. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Do you think the permalink settings are breaking a path somewhere

    It does sounds like something screwy is going on with the rewrites at the server level that is messing with the template hierarchy. WP does use the url to try and determine what template file to use.

  14. ryansigg
    Member
    Posted 2 years ago #

    Ok, then that is what I'll try and I'll report back afterwards. Thanks.

  15. ryansigg
    Member
    Posted 2 years ago #

    OK, the issue is resolved.

    Buried in the media uploads among several identical images, there was an attachment with the exact same name as the page. Setting 'pretty permalinks' made the link pull the attachment page. I'm still confused as to how WP considered the paths the same, especially since the page that wasn't being shown was also a sub-page (so you would think the permalink paths would be quite different)...

    I didn't see it earlier because this user had uploaded multiple instances of the same image. I thought I knew exactly which attachment-image it was pulling, but when I examined the exact path of the image I saw that it was slightly different.

    I've deleted the offending image and uploaded and new, re-named version. Works great.

    Thanks for all your help esmi!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags