WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Linking to pages as nav links w/o using the page name (4 posts)

  1. krimsly
    Member
    Posted 5 years ago #

    Greetings all,

    I'm building a theme that uses the pages as navigation links. I'd like the end user to be able to change the names of the pages w/o the nav links breaking. Each nav link is uniquely styled rather than lending itself to uniform

  2. 's, so I didn't use wp_list_pages().

    My solution to this was to figure out the ID of the pages and retrieve the page links using their ID's, then link to those ID's directly in my theme. That works great, as long as the end user doesn't delete the page :)

    But, I'm wondering if someone has a better solution to this?

    Thanks

    NorthK

  • esmi
    Forum Moderator
    Posted 5 years ago #

    Add a custom field to the relevant pages (something like key:main_nav / value: yes)?

  • krimsly
    Member
    Posted 5 years ago #

    Hmmm, so the custom field (let's call it "Primary Key") for a given page (for example "Contact Us"), would always have the same value, such as "ContactUsUniqueKey". Then I would traverse the list of pages looking for whatever page has that custom field value "ContactUsUniqueKey".

    That way the end user could change the name of the page to "Get In Touch" but it would still have the custom field with value of "ContactUsUniqueKey" which I would look for and know that page is the right one to link to. Is this what you suggest? If so, that might work.

    The advantage of what you suggest is even if they deleted the page by accident, they could re-create it with that custom key/value and it would get linked to properly even though the page ID would be different....good call. Please let me know if I'm understanding you right.

    Thanks

    NorthK

  • esmi
    Forum Moderator
    Posted 5 years ago #

    That's exactly what I meant. :-)

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags