• Resolved jooosty

    (@jooosty)


    The way the ‘more’-button works in wordpress is great. But is it also possible to automatically create a name attribute at every title at your homepage (so at every title of every article)? That way you can directly link to the right place to be at my homepage. The name ID would just be the article ID, so for example (my website is https://www.weerwatnieuws.com), it would look like this:

    https://www.weerwatnieuws.com/#3169

    When clicking on it, you should be directed to the top of the website, but to the part where the article is. Is it possible to change this, and where do I have to do it?

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    from the codex: Customizing the Read More

    By default, when you click on the Read More link, the web page loads and then “jumps” to the spot where the <–more–> tag is set in the post. If you do not want that “jump”, you can use this code in your theme’s functions.php:

    function remove_more_jump_link($link) {
    $offset = strpos($link, '#more-');
    if ($offset) {
    $end = strpos($link, '"',$offset);
    }
    if ($end) {
    $link = substr_replace($link, '', $offset, $end-$offset);
    }
    return $link;
    }
    add_filter('the_content_more_link', 'remove_more_jump_link');
    Moderator keesiemeijer

    (@keesiemeijer)

    Ok sorry, you want the same functonality as the more link for your post titles.
    In your theme look for:
    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    and change like so:
    <h2><a href="<?php the_permalink(); ?>#post-<?php the_ID(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    Thread Starter jooosty

    (@jooosty)

    sorry for my newbieness, but do you mayby know which file i need to have (i’m using titan). I looked through all the files in titan, but can’t really find the file you are mentioning…

    Is this the part you are mentioning?

    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    Thread Starter jooosty

    (@jooosty)

    Never mind, I found it (I think I was dreaming or something, cause it was just in the index.php…).

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding name attribute to articles’ is closed to new replies.