-
Blachut
Hi,
When visitors click on the “Book Summaries” category link — example: https://postimg.cc/QHNdcxq4 — I’d like them to go to this specific post, https://www.thezag.com/book-summaries/, rather than the archive page, https://www.thezag.com/category/books/. Can you please let me know if this is possible and how I might do it?
From what I’ve found in the forums, you can follow this https://docs.wpshowposts.com/article/use-static-pages-as-category-archives/ to make direct category links to static pages/posts. But in my case, I only want to do this for this one category.
Thanks for your help,
Chris
-
Hi Chris,
Does the link only appear in the page hero or it appears in multiple places?
-
Blachut
Hi Ying,
Thanks for your reply. Yeah, the category link at the top of the post is the most important. It also would appear on the site in query loops where the category is in a button over the cover image.
-
Try this simple Javascript which replaces the URL for you.
Create a hook element at appearance > elements, choose
wp_footer
hook, and set the location toposts > all posts
, if there’re other locations that contain the list of terms, add those locations as well.Then add this script:
<script> var element = document.querySelector('.post-term-books'); var link = element.querySelector('a'); link.href = 'https://www.thezag.com/book-summaries/'; </script>
Let me know if this helps!
-
Blachut
Hi Ying,
Thanks. I added the hook element as you suggested. Screenshots here: https://postimg.cc/gallery/vdfc2yH
It’s still not working. i.e., If I go to a post like this one, https://www.thezag.com/dan-pink-drive/, and click the “Book Summaries” button, it takes me to the category archive and not the desired post (https://www.thezag.com/book-summaries/). Could you please help me figure out what I did wrong?
-
What’s the hook name you assigned? I’m not seeing the script being added to your site.
And make sure all cache is cleared.
Let me know 🙂
-
Blachut
Hi Ying,
The name’s in the screenshot I sent you previously: Book Summaries Redirect.
I cleared the cache.
What else could be the reason it’s not working?
-
David
Hi there,
are you using any SEO plugin ? As some of them provide Redirect options for thins like this.
-
Blachut
Hi,
The plugins I use don’t have a redirect functionality, but I can install a simple one that does if necessary.
I was hoping to change the URL on the pages/posts to avoid redirects, but if you say that’s the only option I’ll go with it.
Thanks,
Chris
-
Still not seeing the script being added to your site’s
wp_footer
location, but a redirect plugin should work too.
- You must be logged in to reply to this topic.