It doesn’t have to be an id that is unique to the site – just unique on that page. So if this is a single post page, you could just edit single.php and change:
<h2><?php the_title(); ?></h2>
to:
<h2 id="post-top"><?php the_title(); ?></h2>
Note: Your template markup may vary, so the above is just a generic example.
esmi, thanks very much for your answer.
The problem is that it is not a single post page. So it does not matter where I am, when i click on the “POST-TOP” link it takes me to the very first post of the page, but i would like to go to the top of the current post i’ve clicked. How would I do that?
thank you.
In that case, try:
<h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
But you’ll then need to generate the correct url in your “back to top of post” links. Where you outputting this link in the Loop?
thanks esmi! Now I have something like this on my index.php
<h2 class="contentheader" id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
<div class="content">
<div class="permalink"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Permanent Link</a></div>
<?php the_content('Read more »'); ?>
<?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
<div id="postinfotext">
Posted by: Admin <br />
Date: <?php the_time('d.m.y') ?><br />
Category: <?php the_category(', ') ?><br />
Top:<a href="<???????????????????> POST TOP</a> / <a href="#page" class="top"> PAGE</a>
I have added the code you gave on the first line, now I please need to place the second part on the last line (??????????????????), correct? thanks!
Try:
Top:<a href="#post-<?php the_ID(); ?>">POST TOP</a> / <a href="#page" class="top"> PAGE</a>