• (I searched the forum: no exact matches, and anything close was closed to comments. My understanding of the Codex didn’t yield an answer, either. Hence this post.)

    My custom template uses next_posts_link (and prev_posts_link) in its nav section. These links, as you may know, do not include “rel=next” and “rel=prev” text. I am under the impression that, if I use next_post_link (and prev_post_link) in a proper manner, I may include such text in my links. However, when I place these items in my template, i receive a PHP error claiming these functions are not available.

    Does this mean, simply, that I must rewrite my template and reload it instead of editing it in place (Appearance==> Editor==> Main Template) online?

    Simple advice requested.

Viewing 8 replies - 1 through 8 (of 8 total)
  • First, it is a bad idea to edit main template files. It is better to create a child theme and make edits to the main template files.

    Second, the next_post_link and prev_post_link functions already functions as navigation buttons to load previous or next posts so I don’t see a real need for rel=”next” or rel=”prev” attributes.

    What exactly are you trying to do?

    Thread Starter fjpoblam

    (@fjpoblam)

    First, I don’t understand why it’d be a bad thing to edit main template files in place—I’ve done so many times without negative effect. (It should be noted, of course, that mine’s an extremely simple-minded template, scavenged from Jeff Starr’s H5, and simplified to the point of only index, functions (few to none) and link to master site css).

    Second, yes, I am aware of the intended *use* of the two functions—i.e., providing links to either generic next/previous page in time or specifically the same in a narrowed tag/category search (in the way my template’s defined).

    What am I trying to do? Simply, as I said, including the ”rel” text in the said links. That’s all. (Why? Semantics. Css styling.)

    Thread Starter fjpoblam

    (@fjpoblam)

    [added] The point is, next_posts__link yields html consisting of the *entire* a href=”…” text while next_post_link gives me more granular control over the generated html.

    Yes, I understand that. Have you checked this article out?

    Thread Starter fjpoblam

    (@fjpoblam)

    Yep, I have, and am aware that the meanings of “next” and “prev” are, in effect, reversed. This’ll mean an alteration in the way I define the visible text that goes along with the links in my nav section. However, the topic I’m trying to address here is specifically, the PHP error.

    The “next_post_link” function isn’t found. The “next_posts_link” is.

    The “previous_post_link” function isn’t found. The “previous_posts_link” is.

    Is it impossible to gain access to the “next_post_link”/”previous_post_link” functions via edit-in-place?

    It is not possible to access those functions in order to add the rel tags you want through PHP. It can be possible through jQuery as you can consider a generic example of how below:

    $('.admin_links_node_edit a').attr('rel', 'lightframe');
    Thread Starter fjpoblam

    (@fjpoblam)

    …Okay, thanks. I’ll try to figure out how to expand upon your suggestion for my needs (given my puny knowledge of jquery and lightframe). Yep, I know, I know: “read the instructions.” Thanks again. Really. ??

    Oh, the lighframe is just the value for the rel attribute. In your case, it would be something like:

    $('.prev-link a').attr('rel', 'prev');

    You are welcome. ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘next_post_link versus next_posts_link: PHP error’ is closed to new replies.