WordPress.org

Ready to get started?Download WordPress

Forums

Linking to a post/page from another? (10 posts)

  1. skromta
    Member
    Posted 4 years ago #

    This is probably a really stupid question that I should know the answer to but ...

    How do I link to another page/post on the same blog? Yes I know that I could write Bla but this mean that the link will stop working if I change domain (yep, it recently happened to me). How can I link in a way that is "domain independent"?

  2. s_ha_dum
    Member
    Posted 4 years ago #

    bloginfo('url').'/<pagename> or get_bloginfo('url').'/<pagename>

  3. skromta
    Member
    Posted 4 years ago #

    Hmmm, can I use that directly in a post (from what I understand I can't)?

    So I should write a simple plugin to do this? Or am I missing something?

  4. s_ha_dum
    Member
    Posted 4 years ago #

    Oh... you want to write this inside a post. Sorry. No you can't insert PHP using the editor.

    Though I've never used them before I think I'd cook up a shortcode to do this if it were me. Maybe there is a default shortcode for the purpose. I'm not sure. At any rate, it should be a simple function to write.

  5. Mark / t31os
    Moderator
    Posted 4 years ago #

    You can do it by using links like so..

    /?p=ID

    or

    /wordpress-directory/?p=ID

    ..depending where WP is installed.

    Where ID is the ID for the post, this ensures it will work regardless of your permalink settings, because the ?p=ID will always resolve to the correct post..

  6. skromta
    Member
    Posted 4 years ago #

    Thanks, a small plugin made it work as I wanted.

  7. s_ha_dum
    Member
    Posted 4 years ago #

    Do you mind telling us what the plugin was?

  8. skromta
    Member
    Posted 4 years ago #

    Ohh, just something that I hacked together myself

  9. Mark / t31os
    Moderator
    Posted 4 years ago #

    I like this one personally(having just searched)...
    http://wordpress.org/extend/plugins/link-to-post/

    No need to know a post or pages ID. Works in both visual and HTML modes..

    I was going to write a basic one, but there's no need when a decent one exists.. :)

    Or if you want a more simple one, there's also this.
    http://wordpress.org/extend/plugins/easy-post-to-post-links/

  10. skromta
    Member
    Posted 4 years ago #

    The first one doesn't solve my problem, it generates a full anchor-tag which is what I wanted to avoid, the second on the other hand works more or less the same way as mine.

    But ... I'm going to take a closer look at the code for the first one and see if I have the time to take a few ideas from there to improve mine (easier entering the id). Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags