how to replace the selected post URL with another?
-
On the home page I would like to replace the post URL for another. I wrote the script:
function myFunction() { var x = document.querySelectorAll('a[href="https://www.freuciv.com/2020/02/10/wozu-brauchen-sie-die-weinreste-geheimnisse-der-gastronomiebranche/"]'); var i; for (i = 0; i < x.length; i++) { x[i].href = "https://www.freuciv.com/?fwp_typ=geheimnisse-der-gastronomiebranche&fwp_sort=title_asc&hideParent"; } } myFunction()(Why do I need it? Look at the URL of the first featured post: “Wozu brauchen sie die Weinreste? Geheimnisse der Gastronomiebranche.” It doesn’t lead to any post, but to search results. In this case, the book chapters are searched: Chapter 1, 2, 3…)
Everything works, but there is a problem. When I click the “load more” button, which loads more posts, the script must be run again. So I assigned (for now in the console) this function to the button, but it runs before the posts appear.
document.querySelector("#load-more-button button").addEventListener("click", myFunction);It could run with a delay, but this solution seems to be very inelegant, doesn’t it? But there is another problem: after running the function disappears from the button. What should I do to keep it there?
So how better to solve this problem? Is there any clever way to replace the selected post URL with another?
- This topic was modified 6 years, 2 months ago by .
- This topic was modified 6 years, 2 months ago by .
- This topic was modified 6 years, 2 months ago by .
The page I need help with: [log in to see the link]
The topic ‘how to replace the selected post URL with another?’ is closed to new replies.