Prev/Next post only within specific tag
Permalink
Hi,
I'm building a photoblog and if a user selects a certain tag, like Portraits, I show them the latest blog post with that tag. Accordingly, I want the Prev/Next post link only to point to posts with that tag.
I would actually prefer it to have the chosen tag added in the url. Then, if I link to a post in Facebook, I'd can send them so a certain series of posts with that tag.
I'm building a photoblog and if a user selects a certain tag, like Portraits, I show them the latest blog post with that tag. Accordingly, I want the Prev/Next post link only to point to posts with that tag.
I would actually prefer it to have the chosen tag added in the url. Then, if I link to a post in Facebook, I'd can send them so a certain series of posts with that tag.
Does anybody have an idea to solve this??
I assume that you are using "Previous/Next Page" block, right? Then don't use it.
Enable pagination in page list block. It should work more or less like you described in your post.
Enable pagination in page list block. It should work more or less like you described in your post.
Thanks for your reply, but it is not what I'm looking for. The pagination you refer to is to go to the next list of pages, not directly to visit the next page in that list.
Somehow I need to pull a list of pages with a certain tag, that is mentioned in the url. Then generate a Prev and Next link using that list.
Somehow I need to pull a list of pages with a certain tag, that is mentioned in the url. Then generate a Prev and Next link using that list.
Add this issue to github. The prev/next need to be with more "build in" options - "by topic / by tag" (not only by "level" in site tree).
I see. I think Prev/next block doesn't have option to work with tags (or topics) by default.
It depends how you set up displaying latest post. Are you using page list block (with filtering by tags enabled), right? Either way it requires some custom coding.
If you enable pagination in page list block and display only 1 page at once - then "next list of pages" is the same as next page. You need only then to make custom template for pagination (to get rid 1,2,3 etc. numbers). This will display only one element per page and prev/next urls will look like:
latest post: yoursite.com/tags/tag/tagname
second post: yoursite.com/tags/tag/tagname?ccm_paging_p=2
third post: yoursite.com/tags/tag/tagname?ccm_paging_p=3
And yes, your next/prev urls will not look like that:
yoursite.com/gallery/item-1
To even meet your requirements in that case ("Then, if I link to a post in Facebook, I'd can send them so a certain series of posts with that tag.") your urls should look at least something like that:
yoursite.com/gallery/item-1?tag=tagname
or your post need to have only one tag added
2. Another idea is to modify previous/next page block, but again your url need to look like
yoursite.com/gallery/item-1?tag=tagname
or your post need to have only one tag added
3. If it is still doesn't meet your requirements - probably creating custom pagetype/doing some coding in template is the way to go.
It depends how you set up displaying latest post. Are you using page list block (with filtering by tags enabled), right? Either way it requires some custom coding.
If you enable pagination in page list block and display only 1 page at once - then "next list of pages" is the same as next page. You need only then to make custom template for pagination (to get rid 1,2,3 etc. numbers). This will display only one element per page and prev/next urls will look like:
latest post: yoursite.com/tags/tag/tagname
second post: yoursite.com/tags/tag/tagname?ccm_paging_p=2
third post: yoursite.com/tags/tag/tagname?ccm_paging_p=3
And yes, your next/prev urls will not look like that:
yoursite.com/gallery/item-1
To even meet your requirements in that case ("Then, if I link to a post in Facebook, I'd can send them so a certain series of posts with that tag.") your urls should look at least something like that:
yoursite.com/gallery/item-1?tag=tagname
or your post need to have only one tag added
2. Another idea is to modify previous/next page block, but again your url need to look like
yoursite.com/gallery/item-1?tag=tagname
or your post need to have only one tag added
3. If it is still doesn't meet your requirements - probably creating custom pagetype/doing some coding in template is the way to go.