[Support request] "#main" at the end of every attachment URL

Home Forums Support [Support request] "#main" at the end of every attachment URL

Home Forums Support "#main" at the end of every attachment URL

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #978230
    Vish

    I am using generate press on a couple of sites and in all of them, if I look at the attachment URL, there is a “#main” added at the end of the URL.

    For example, let’s say the URL of the attachment is:

    https://example.com/post-name/attachment-name/
    But it actually shows the attachment URL as below:
    https://example.com/post-name/attachment-name/#main

    I have enabled attachment sitemap in one of the sites and all the attachment links in the sitemap have “#main” at the end.

    I don’t want the ‘#main’ part and would like to remove the same. Please help. I have provided a sample URL too.

    #978233
    Leo
    Staff
    Customer Support

    Hi there,

    GP doesn’t control the URL structure at all.

    I would recommend checking your WordPress permalink settings first:
    https://wordpress.org/support/article/settings-permalinks-screen/

    if that doesn’t help then maybe ask your host to see if they can see what’s causing this.

    #978264
    Vish

    Permalink settings are literally the first thing I checked. To give more information to you, here’s what I did:

    1. Disabled all the plugins in the site. Everything, including GP Premium. So, now it’s just bareboned GP theme.
    2. Uploaded a new image to a post.
    3. Checked the URL in the Media page. SAME thing happens.

    No plugins, usual settings in wordpress permalink settings > still the same result.

    I checked the Media Attachment link in another site which runs on Genesis, the URL is clean without ‘#main’ at the end.

    Could you please try this at your end?

    1. Make a post.
    2. Insert an image.
    3. Publish the post.
    4. Go to Media.
    5. Open the image.
    6. Check the image attachment URL.

    If you still insist this has nothing to do with GP, I will create clean WP install and try out the same.

    Let me know. πŸ™‚

    #978269
    Leo
    Staff
    Customer Support

    what happens if you activate a WordPress default twenty series themes?

    #978321
    Vish

    Here’s what I did:

    1. Created a FRESH WordPress Install.
    2. Updated the Twenty Seventeen Theme to Latest Version.
    3. Created a Post > Added an attachment > Published.
    4. Media > Click on the image to open it > Look at the URL here: https://ibb.co/HHJm8fs
    5. Installed the GeneratePress Theme (No GP Premium, just the theme from WP Repository).
    6. Created a Post > Added an attachment > Published.
    7. Media > Click on the image to open it > Look at the URL here: https://ibb.co/HCCNZr1

    As expected, GeneratePress definitely has something to do with it. And no, there were NO plugins installed.

    If it is not too much trouble, could you please try this at your end? To see it for yourself?

    Let me know if I can do anything more to help understand the problem.

    #978368
    Leo
    Staff
    Customer Support

    Not able to replicate it on my install:
    https://www.screencast.com/t/orNStX8ID0O

    Haven’t had other reports on this either but I’ll forward it to Tom and see if he has any ideas πŸ™‚

    #978437
    Vish

    That is very strange! I tried on multiple GP installed sites and also on fresh installs; the same results every time.

    Hi Tom,

    If you are reading this, I’m still waiting for a solution. πŸ™‚

    Even some sort of function to rewrite the URLs would be great. I have tried looking for solutions everywhere – nothing useful. Everywhere it says that WordPress by default doesn’t do this and only a plugin/theme would be to blame. Since I tried this on a fresh install with ONLY GP installed, I am sort of inclining towards the theme.

    Any help on this would be appreciated. Thanks.

    #978575
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try adding this PHP:

    add_action( 'after_setup_theme', function() {
        remove_filter( 'attachment_link', 'generate_enhanced_image_navigation', 10, 2 );
    } );

    Let me know πŸ™‚

    #979155
    Vish

    Awesome; it worked! Thanks, Tom! πŸ™‚

    #1020162
    Irvan

    Thanks, Tom! I have the same problem and your code works!

    #1020577
    Tom
    Lead Developer
    Lead Developer

    Awesome! πŸ™‚

    #1189987
    Nordin

    Had the same problem. Tom’s code works.

    Perhaps it has something to do with the used theme from the site library? In my case it’s broadcast.

    #1190225
    Tom
    Lead Developer
    Lead Developer

    It’s a standard function in the theme. It’s so the browser jumps down to the main content area (the image), instead of forcing the user to scroll down.

    #1308257
    Vish

    Tom, the code you provided does not work. I just tried it on a new site and it is not working.

    Any update needed for the code work?

    Thanks.

    #1308835
    David
    Staff
    Customer Support

    Hi there,

    nothing has changed with that filter
    Can you share a link to show where it is not working ?

Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.