- This topic has 22 replies, 6 voices, and was last updated 3 years, 6 months ago by Ying.
-
AuthorPosts
-
August 7, 2019 at 8:42 am #978230Vish
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/#mainI 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.
August 7, 2019 at 8:44 am #978233LeoStaffCustomer SupportHi 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.
August 7, 2019 at 9:08 am #978264VishPermalink 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. π
August 7, 2019 at 9:10 am #978269LeoStaffCustomer Supportwhat happens if you activate a WordPress default twenty series themes?
August 7, 2019 at 9:57 am #978321VishHere’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/HCCNZr1As 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.
August 7, 2019 at 11:10 am #978368LeoStaffCustomer SupportNot able to replicate it on my install:
https://www.screencast.com/t/orNStX8ID0OHaven’t had other reports on this either but I’ll forward it to Tom and see if he has any ideas π
August 7, 2019 at 12:37 pm #978437VishThat 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.
August 7, 2019 at 4:28 pm #978575TomLead DeveloperLead DeveloperHi there,
Try adding this PHP:
add_action( 'after_setup_theme', function() { remove_filter( 'attachment_link', 'generate_enhanced_image_navigation', 10, 2 ); } );
Let me know π
August 8, 2019 at 8:42 am #979155VishAwesome; it worked! Thanks, Tom! π
September 26, 2019 at 11:44 pm #1020162IrvanThanks, Tom! I have the same problem and your code works!
September 27, 2019 at 8:52 am #1020577TomLead DeveloperLead DeveloperAwesome! π
March 9, 2020 at 11:08 am #1189987NordinHad 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.
March 9, 2020 at 4:55 pm #1190225TomLead DeveloperLead DeveloperIt’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.
May 30, 2020 at 9:22 pm #1308257VishTom, 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.
May 31, 2020 at 8:46 am #1308835DavidStaffCustomer SupportHi there,
nothing has changed with that filter
Can you share a link to show where it is not working ? -
AuthorPosts
- You must be logged in to reply to this topic.