• Resolved sam

    (@samjoelnang)


    I have a blog that’s available in two languages using Polylang. I have a taxonomy called?artists?under which several?artist names?serve as terms. When writing, the practice is to hyperlink the artist’s name when it is first mentioned. I do this by highlighting the same and inputting only the subdirectory?/artists/example-artist?(as opposed to writing the home URL + the subdirectory). This results in the hyperlinked artist name having the link https://www.exampleblog.com/artists/example-artist, which is correct.

    I recently decided to turn?artists?into a multilingual taxonomy, hence, there now exists equivalent archives in the second language for each artist name. An archive for an artist may now be found at https://www.exampleblog.com/artists/example-artist or https://www.exampleblog.com/ph/artists/example-artist, depending on the current language.

    Basically, I’m trying to make all hyperlinked artist names inside a post go to the correct archive version depending on the language set, especially while in the second language that should have the?/ph?before the subdirectory /artists/example-artist.

    I do not have issues when a single post with such hyperlink is viewed on the main language, however, inside a single post in, say, the Philippine version (https://www.exampleblog.com/ph), a hyperlinked artist name does not link to?https://www.exampleblog.com/ph + /artists/example-artist?and remains as is?https://www.exampleblog.com/artists/example-artist, thus this question.

    All links on the blog return to the?correct /ph?home when the website is switched to that language. I only have a problem with this second language home URL not being recognized inside the post.

    Regardless if there’s Polylang or not, is it possible to change a blog’s default home URL within a single post so when a hyperlink written only with the subdirectory will automatically get attached to that URL on the front-end? Appreciate any advice.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Unfortunately, your wish will not be feasible. This is due to simple HTML rules and the links that you have added manually. The links you have stored begin with a “/”, which means that even a different HTML base URL specification does not lead to them opening relatively (i.e. under /ph) but absolutely (under /artist).

    I’m not sure which editor you are using to edit the content? In the block editor you can select links to taxonomies as such. This means that the link is stored dynamically and any subsequent changes to the URLs will also affect them.

    In your case, unfortunately, I can only see the possibility of manually adjusting the links at the moment. You would have to change the URLs manually on the respective language-specific pages.

    Moderator bcworkz

    (@bcworkz)

    is it possible to change a blog’s default home URL within a single post so when a hyperlink written only with the subdirectory will automatically get attached to that URL

    I think you are wanting to utilize a relative link such as <a href="ph/">Link</a> instead of a full, absolute URL? Even assuming that is possible, because of how WP manages URLs, relative links are not advised. While it might achieve your immediate goal, it’ll also possibly result in unanticipated links that are invalid and result in 404 not found errors. Getting 404s for what should be a valid resource will be bad for your site’s SEO. My advice is to stick with full absolute URLs within WP environments.

    Thread Starter sam

    (@samjoelnang)

    @threadi and @bcworkz, thanks for your input. I am marking this Topic as resolved as I found out taxonomies in fact get suggested as destination URLs together with posts and pages when hyperlinking a word or a phrase. I just got so used to typing /artists/artist-name right away I completely missed utilizing the core functionality of linking to a taxonomy page by simply choosing the same from the suggestions in the dropdown. All along I thought custom taxonomies don’t show up there. I confirm that the automatically suggested taxonomy page URL even corresponds to the language I am writing in. Thus, I didn’t have to modify the home URL within a single post at all, just had to look closely!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.