Skip to content

Feature/filter nav urls#31

Merged
sbrody merged 2 commits into
mainfrom
feature/filter-nav-urls
May 15, 2026
Merged

Feature/filter nav urls#31
sbrody merged 2 commits into
mainfrom
feature/filter-nav-urls

Conversation

@sbrody
Copy link
Copy Markdown
Contributor

@sbrody sbrody commented May 13, 2026

Description of changes

This PR adds a filter to the url passed to each chapter navigation item. It's purpose is to allow a custom value, such as a preview link open to non logged-in users, to be output.

To test it works, open a long read with several child pages. Paste something like the following into templates/functions.php

add_filter('long_read_plugin_chapter_url', function($url, $postID) { if ($url) { return 'https://bbc.co.uk/'; } return $url; }, 10, 2);

All the links in the nav should now go to bbc Remove the code and the links should go to their expected destination.

If you use the code above the pagination links will disappear because there will be no

Checklist

  • Changelog updated
  • If new release: major version tag to be bumped after release (see docs)

sbrody added 2 commits May 13, 2026 16:56
Will allow custom url to be supplied, for
example to replace with preview link for non
logged in users. Post ID is also set before the foreach
loop so it can be reliably passed to the filter
without being reset by get_permalink
@sbrody sbrody force-pushed the feature/filter-nav-urls branch from a5d1b1e to d0bbba7 Compare May 13, 2026 15:56
@eirichmond
Copy link
Copy Markdown

@sbrody if I follow correctly and add this filter to /wp-content/themes/ukss/templates/functions.php nothing seems to happen to the Chapter navigation for non logged in or otherwise, what am I missing here?

@sbrody
Copy link
Copy Markdown
Contributor Author

sbrody commented May 14, 2026

@sbrody if I follow correctly and add this filter to /wp-content/themes/ukss/templates/functions.php nothing seems to happen to the Chapter navigation for non logged in or otherwise, what am I missing here?

Do the chapter navigation links not change to bbc.co.uk?

@eirichmond
Copy link
Copy Markdown

@sbrody if I follow correctly and add this filter to /wp-content/themes/ukss/templates/functions.php nothing seems to happen to the Chapter navigation for non logged in or otherwise, what am I missing here?

Do the chapter navigation links not change to bbc.co.uk?

for me they remain the same if I've added the filter in the right place, if I debug the filter then the $url is never returned - which is why I'm not sure if I have things setup up correctly, if you provide the exact steps to replicate it working that would help as I'm not sure if its further up the chain of logic as to why my setup isn't working.

@sbrody
Copy link
Copy Markdown
Contributor Author

sbrody commented May 14, 2026

@sbrody if I follow correctly and add this filter to /wp-content/themes/ukss/templates/functions.php nothing seems to happen to the Chapter navigation for non logged in or otherwise, what am I missing here?

Do the chapter navigation links not change to bbc.co.uk?

for me they remain the same if I've added the filter in the right place, if I debug the filter then the $url is never returned - which is why I'm not sure if I have things setup up correctly, if you provide the exact steps to replicate it working that would help as I'm not sure if its further up the chain of logic as to why my setup isn't working.

I think it might be worth us having a call tomorrow to see if we can work it out

Copy link
Copy Markdown

@eirichmond eirichmond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works

@sbrody sbrody merged commit 34be37e into main May 15, 2026
2 checks passed
@sbrody sbrody deleted the feature/filter-nav-urls branch May 15, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants