Feature/filter nav urls#31
Conversation
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
a5d1b1e to
d0bbba7
Compare
|
@sbrody if I follow correctly and add this filter to |
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 |
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