• Hello there,

    I have a gaming blog and am trying to make navigation easier for users who are looking to find video trailers in posts.

    I have created a ‘trailers’ category which is shown as a menu item. This is used to display the list of posts that have trailers in them. In each post I have then created an anchor text like this: <h3 id=”trailers”>Trailers</h3>

    How do I make it so that when users click on the link to the post, it will then load that post and automatically move down the trailers section of that post?

Viewing 7 replies - 1 through 7 (of 7 total)
  • wpismypuppet

    (@wordpressismypuppet)

    Thread Starter Robert Roy

    (@robertjroy)

    Thank you for that, looks like it will do the trick.

    However, how do I change the link that is generated by the ‘trailers’ category to include the link to the bookmark?

    wpismypuppet

    (@wordpressismypuppet)

    There are a number of ways to do that, but I’d need to see how you currently are getting a list of categories and their links. Then I can give you the correct information.

    Thread Starter Robert Roy

    (@robertjroy)

    No problem, I appreciate your help. You can view the website at https://www.theparadym.co.uk.

    I would like to add the bookmarks to the links in https://www.theparadym.co.uk/trailers/

    wpismypuppet

    (@wordpressismypuppet)

    To get this straight, you want people who visit this page:

    https://www.theparadym.co.uk/trailers/

    To click any one of the titles… “Watch Dogs” for example… and be brought to this page:

    https://www.theparadym.co.uk/games/watch-dogs/

    But scroll down to “trailers”. Correct?

    Thread Starter Robert Roy

    (@robertjroy)

    Yes, that’s exactly what I want. The pages are currently stubs but will be much longer once they’re complete, hence why it’ll be useful to have them automatically moved to the correct place.

    wpismypuppet

    (@wordpressismypuppet)

    Ok… so here’s the deal.n On the page that generates this page:

    https://www.theparadym.co.uk/trailers/

    Find where the title is being pumped out. It might be index.php for all I know, but you’ll want a template file for this page regardless since you want to add #trailer to the end of those anchor tags, and you don’t want that to be appending to just any post. Are you familiar with making a template?

    Once you find where the title is being pumped out, you’ll see the code that makes the anchor tag enclosing it… Might look something like:

    echo '<h4><a href="'.get_permalink().'">'.get_the_title().'</a></h4>';

    Simply change it to look like this:

    echo '<h4><a href="'.get_permalink().'#trailer">'.get_the_title().'</a></h4>';

    Then, on the page that is generating these “pages”:

    https://www.theparadym.co.uk/games/watch-dogs/

    Where you are pumping out the word “Trailers” add the bookmark. So I believe you have:

    <h3 id="trailers">Trailers</h3>

    Change it to:

    <h3 id="trailers"><a name="trailer"></a>Trailers</h3>

    Just make sure the name=”trailer” matches #trailer. You don’t want name=”trailer” and then #trailers as that won’t work. Just duplicate this method for Games, News, whatever…

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Using Anchor Text’ is closed to new replies.