Support » Plugins and Hacks » Hacks » ID tag to read-more

  • Resolved Sinopa

    (@sinopa)


    Hi.

    Does anyone know how I can add an id tag to the read-more?

    <a href="http://localhost/?p=41#more-1" ID="MYMORESTYLE" class="more-link">

Viewing 10 replies - 1 through 10 (of 10 total)
  • function new_excerpt_more($more) {
      global $post;
      return '<a href="'. get_permalink($post->ID) . '" id="whatever">Read the Rest...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    You can see more here.

    Oh. Forgot to add that I use the_content, and not excerpt.

    Michael

    (@alchymyth)

    Forum Moderator

    what is the purpose of adding a css id to the more link?

    – the link can be perfectly styled based on the css class .more-link;

    – using more than one post with this link on one web page would output multiple elements with the same css id, i.e. create invalid code.

    unless MYMORESTYLE is unique per post, in which case the next question is, where would it come from?

    I’m sorry alchymyth, but I just need it without using a lot of time explaining why I need it.

    Michael

    (@alchymyth)

    Forum Moderator

    does it need to be unique per post?

    That part I have fixed. I just need to add an id=”” to the read more tag

    *LOL* Ask and ye will receive a thousand questions in return, but ye will not receive an answer 😀

    Michael

    (@alchymyth)

    Forum Moderator

    try this filter function:

    add_filter( 'the_content_more_link','more_link_css_id',10,2);
    function more_link_css_id($link,$link_text) {
    global $post;
    $link = '<a href="' . get_permalink($post->ID) . "#more-{$post->ID}\" class=\"more-link\" id=\"more-link-id-{$post->ID}\">$link_text</a>";
    return $link;
    }

    this example would add the css id #more-link-id-123

    Thank you very much alchymyth 🙂

    I will try it right away 🙂

    OMG! It worked! Thank you, Thank you, Thank you alchymyth 🙂
    Been trying to find a solution on Google, but didn’t find any.

    Thank again alchymyth. You saved my day 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘ID tag to read-more’ is closed to new replies.