• Resolved piblondin

    (@piblondin)


    Hi everyone,

    I’m trying to get the the URLs for the next and previous posts links, i.e. what would typically be called the “Older Posts” or “Next Page” on the homepage index.php. The code I have for the next posts is

    <?php next_posts_link(__('Older posts', '5years') . ' &rarr;') ?>

    However, I only want the URL, not the entire link code. What is the PHP function that will call just that URL?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter piblondin

    (@piblondin)

    For clarification, ‘5 years’ is the theme I’m using. Thanks to anyone who can help!

    i haven’t found a direct function to do this.

    however, you could try this snippet to get just the link url:
    <?php $npl=explode('"',get_next_posts_link()); $npl_url=$npl[1]; ?>

    get_next_posts_link() gets the link as a string (example)
    <a href="http://localhost/wordpress/page/2/" class="nextpostslink">Next Page &raquo;</a>
    then breaks it into an array at the ” ,
    and uses the second array element which holds the url
    localhost/wordpress/page/2/

    Thread Starter piblondin

    (@piblondin)

    Excellent! Thank you much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get URL for next posts page?’ is closed to new replies.