Hi,
Is there any way or any tags that can return the 'raw' link to previous/next posts? eg. http://mysite.com/post/
Have tried various tags, but they all return .
Am trying to put the previous/next post link in javascript.
Hi,
Is there any way or any tags that can return the 'raw' link to previous/next posts? eg. http://mysite.com/post/
Have tried various tags, but they all return .
Am trying to put the previous/next post link in javascript.
get_previous_post() and get_next_post() are defined in wp-includes/template-functions-links.php.
You could use these functions, and also review previous_post_link() and next_post_link() (both of which echo instead of return) for how to obtain the links you need.
Want to put the link in the code location.href=(link)
Using get_previous_post() gives
location.href=('')
while using previous_post_link() gives
location.href=('« <a href="http://mysite.com/link">Post title</a>')
Have tried putting 'echo get_previous_post()' which gives location.href=('Object')
Any ideas?
n.b. In above post,
Have tried various tags, but they all return .
should be
Have tried various tags, but they all return <a href="http://mysite.com/link"></a>.
get_previous_post() returns an actual post object. With this object, you could then feed the previous post's ID to get_permalink().
Also take a look at the arguments accepted by previous_post_link() and next_post_link() for ways to control and format the link.
Check out these wp-codex pages, you might find a solution for what you want to do:
http://codex.wordpress.org/Template_Tags/previous_post
http://codex.wordpress.org/Template_Tags/next_post
This topic has been closed to new replies.