Forums

Create an HTML anchor tag containing post ID (3 posts)

  1. tnybutler@gmail.com
    Member
    Posted 1 year ago #

    Hi,

    I'm new to WordPress and have read through the documentation in the 'Docs' section; have also searched the forums for this but cannot find anything quite like what I want to do.

    My site has a list of recent posts showing only the title of the post. I want these to be hyperlinked, so that when the user selects the link they are taken to another page to view the whole post. I'm not using a template, because - I'll be honest - I don't really have time to expend on getting the best out of a template.

    How can I create a standard HTML anchor tag to include the ID of a post? Also, on the destination page, what do I have to do to pass the ID to the WP store of posts to retrieve the content of the post?

    Thanks in advance.
    TB

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    My site has a list of recent posts showing only the title of the post. I want these to be hyperlinked, so that when the user selects the link they are taken to another page to view the whole post.

    a hyperlinked title - linking to the single post - would look like this, for instance:

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    (assuming this is in a wordpress loop)

    Also, on the destination page, what do I have to do to pass the ID to the WP store of posts to retrieve the content of the post?

    the permalink links to single.php, so there is no need to do anything.

    unless you want to do something more complicated, in which case you need to provide more details.

  3. tnybutler@gmail.com
    Member
    Posted 1 year ago #

    Thanks very much for replying Alchymyth. This is very helpful.

    Best regards,
    TB

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags