Change URL on attachments (image.php)
-
I use the latest version and Twenty Fifteen (latest parent) and child.
I would like to have the attachments URL changed and can’t find a good tutorial of how to do it. Is it possible?
More specific, I don’t want the attachments ID in the URL, I want the attachments title (a seo-friendly) one.
Kindly asking,
Caroline
-
Enable pretty permalinks in your settings?
I’m not trying to be flip, my site does this without any special hacks, only changing permalinks from default. I have 4.3 and twentyfifteen as well. Of course, this applies to all URLs, not just attachments, which would be desirable for SEO anyway.
Hello bcworkz!
I’m so glad you answered me, it means everything!But a lot happens in a week for me and i’ve been struggling and working around the clock — a literally week.
The new question is similar: how can I replace the full image with the ones in the sidebar when I click on them? Here –> https://www.makeupedia.se/produkt/apolosophy-nail-polish/posh-orange-27
I believe there must be a prefix/suffix change in the URL to do this, so would love to get some help!
I do understand what a struggle this can be, believe me.
I’m not sure how you got to where you are, so it’s difficult to give explicit advice. Generally speaking, when you insert a picture from the media library, you can specify where the image’s link leads to – no link, attachment page, the full image, or a custom URL. The attachment page choice URL should appear as discussed above, depending on the permalink type selected.
The user experience you describe sounds much like the default image gallery, except the thumbnails would appear on every page instead of only the first page. While some custom coding could achieve this change, it may also suffice to place the thumbnail page HTML in a sidebar, but then changes would be tricky to accomplish.
Your best approach would be to find an image gallery plugin that works the way you want. There are many different ones available. Do not be concerned with a plugin’s appearance, that can be changed with CSS. Focus on how the plugin functions, that is more difficult to change.
Off topic if I may — it’s an amusing coincidence your site is Swedish. While I normally reside in the US, I was just in Sweden! A beautiful country indeed. Right now I’m in Finland working on an unrelated project and giving out WP advice as a diversion from what I should be doing ??
I tried and tested lots of plugins and other functions to end up here!
I found something good in WP Types, this plugin can add/attach already published images into a new post type (mine CPT are product). It generates the image URL to a custom field value. I’ve been trying to build a link href here without luck.Another great and simple code I want to use it this one. It shows links to the child posts but sadly no thumbnails:
<?php $children = wp_list_pages('title_li=&child_of='.get_the_ID().'&post_type=produkt&echo=1'); if ($children) { ?> <ul> </ul> <?php } ?>
But as you say I will keep look for galleries and plugins.
—
Oh so you’re the american with the passport! (Haha sorry just had to no offence:)
Sounds really fun, did you gave some wp advice in stockholm? I wish you the best!Getting child thumbs is not so difficult with wp_get_attachment_image(). Getting the related link to display a large image on the same page is more difficult, which is why I suggested a plugin. I realize how difficult it is to find just the right plugin.
A bit of custom coding can often get a plugin to conform to your needs. Unfortunately, some plugins are not configured well for custom coding. But others are, so there is hope.
Another possibility would be each thumb links to a page with a custom template. While this is workable, the user experience leaves much to be desired as each click causes the entire page to reload. Loading individual images onto the current page with AJAX is much more desirable, but the code is more complex. This is hopefully where a plugin would help.
—
Yes, I’m that American! ?? You are too funny. I take no offence, but my boring countrymen should, except they probably would not know they are insulted ?? No WP advice given when in Sweden as I was then playing tourist and had little time and no need for diversion.Hi again! I’ve been working on this and found a solution (for now)!
I don’t mind the entire page to reload, but as you say the coding will take a while for me to do so. So I managed to find a nice pop up plugin, which is thankfully also responsive. The plugin I use is wp featherlight (or something). It works fine and simple after I have insert the thumbnails + links as custom fields values and then echo it in my custom template. Works ok for now!
But, I also found out in YOAST SEO I could easily redirect the attachments/images to the same page. This could be something to work on as well.
—
Haha yeah I should just keep my mouth shut, since I haven’t renewed my passport myself ??
Good to hear you’ve had some success. You have a good plan — get it working (done!); make it better (find time)
Yes, redirecting has possibilities. Ultimately, AJAX is still the best solution IMO. Meh, I’m repeating myself. Perhaps you’ll get there someday. At least you know where to get help.
—
At least you have a passport. There’s some very diverse places within the Schengen zone where no one would notice your expired passport ??Thanks! Yes I will look into AJAX some day, right now I’m swamped with newly learned things that need to be processed, hahaha!
—
yeah I believe you!
- The topic ‘Change URL on attachments (image.php)’ is closed to new replies.