WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] link to single page post of first post? (6 posts)

  1. Skeary
    Member
    Posted 5 years ago #

    I want a link to the first post to be permanently on the sidebar but I don't know how to code it and can't find anything in the codex. I tried linking to post#1 but that just put it in the loop so it wasn't within single.php.. I want to link directly to the single post view. How could I do that?

  2. Mark / t31os
    Moderator
    Posted 5 years ago #

    <?php echo get_permalink(X); ?>

    Would be the safest approach...

    Replace X with the ID number of said post..

    Example:
    <?php echo get_permalink(10); ?>

  3. Skeary
    Member
    Posted 5 years ago #

    cool thx! now i just need to get it to work with the image I want it linking..

    <a href="<?php echo get_permalink(1); ?>">
    <img  class ="nav" src="<?php bloginfo('template_directory'); ?>
    /images/start.gif" alt="go to the first entry"/></a>

    just links to the homepage, so I think I gotta do something a little different.

  4. Mark / t31os
    Moderator
    Posted 5 years ago #

    So you're sure 1 is the correct ID for the first post you have?..

    Just because it's the first post doesn't mean the ID is 1...

  5. Skeary
    Member
    Posted 5 years ago #

    you're good! lol yeah.. i shoulda realized.. it's 43, not 1.

    thanks a lot for the fix.

    i dunno if it's just me but the codex seems a bit hard to locate things in.

  6. Mark / t31os
    Moderator
    Posted 5 years ago #

    Yes it is a bit here and there right now...

    The best thing you can do is ask here, if anyone knows where to find it in the codex they'll post a link for you...

    If it's not in the codex we can still provide whatever info you need about a tag or function right here....

Topic Closed

This topic has been closed to new replies.

About this Topic