Archived topic
How to create re-usable button to "current tag archive"
7 replies · Started by Marcel on July 1, 2022
Hi,
I'm looking all over the forum and internet to find the following solution:
I want to create a re-usable button that automatically links to the current post tag archive (there is only 1 tag on each post)
Any idea how to do this so I can re-use it on many single posts?
Kind regards,
Marcel
Hi there,
do you really want to add that button inside your post content ?
When you could just display in your post meta.
Let me know.
Hi David,
thanks for your quick response.
Actually it is a replacement for the pagination of a query loop we now use on posts with a tag. Reason: the query loop is at the end of a post and when clicking on "next page" within the pagination of the query loop the whole page is reloaded and focussed on top. So a visitor is confused "I clicked next but now the page is reloaded, what now?".
I want to resolve this by adding a button with a generated link to the tag archive and re-use that button code for all the posts with unique tags.
Is it possible to see one of these posts ? May give me some pointers for the best solution, as ideally it would be best to avoid manually adding this kind of thing.
The site is still in development but I added an URL of 1 whitelisted post so you can check.
At the end of the post you see 2 query loops, the first loops news posts but there are not enough yet to paginate (although since last update of GB the pagination is showing but not working of course). The second query loop loops specific CPT from TEC (The events calendar), there we have already enough posts to show pagination.
The best solution is that the GB query loop pagination is with AJAX so it's all "inline"?
Ok, so you can just add a GB Button after the query loop and enable its dynamic data options:
https://www.screencast.com/t/LsGBGKUbSt
Ajax loading and other clever things will be added to a future GB Pro update.
Thanks David,
I'll try to find the best interim solution until the Ajax loading will be there, we have GB PRO so can't wait for the update ;-)
You're welcome