WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Single Post previous and next links (2 posts)

  1. catalpha
    Member
    Posted 3 years ago #

    How can I modify:

    <?php previous_post_link('« %link') ?> | <?php next_post_link('%link »') ?>

    in single.php to NOT display the post title as a link, but something like "next" or "previous" instead?

    All code for single.php:

    [code removed as per forum rules - please use the pastebin]

  2. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    Refer to the Codex entry for previous_post_link().

    previous_post_link( $format, $link, $in_same_cat, $exclude_categories ) accepts four arguments:
    - $format: string format of the link, using the %link% placeholder for the HTML link. Default: "%link% »"
    - $link: text (string) to display within the HTML link. Default: "%title%" (Post Title)
    - $in_same_cat: boolean (TRUE/FALSE) value to specify if linked post must be in the same category as the
    current post. Default: FALSE
    - $exclude_categories: list of categories by ID, separated by 'and', to exclude. Default: none.

    So, to display "Previous", rather than the Post Title, change the second argument to "Previous", rather than "%title%"

Topic Closed

This topic has been closed to new replies.

About this Topic