Search code examples
phpechopermalinks

permalink that goes straight to a div within a post


I was wondering what is the php code to go directly to a div on single post on a wordpress page (comments)

For example. The link to go to the comments section of a particular post would be http://badsentinel.com/2013/05/06/afternoon-awesomeness-41-photos-2/#idc-container (I am using Intense Debate comment plugin) But I dont want to manually type the a href on every single post.

I would like to know if someone can help me out with the below code. Im sure it is something similar..

<a href="<?php echo get_permalink($post->#idc-container); ?> Jump to Comments </a>

Thanks in advance Paul


Solution

  • Since the comments div anchor has a constant identifier you don't need any PHP to refer to it. Just add it after the dynamic post link:

    <a href="<?php echo get_permalink({{id}}); ?>/#idc-container" /> Jump to Comments </a>
    

    replace {{id}} with the post ID

    That being said, if you are using an internal anchor tag, you don't even need the permalink:

    <a href="#idc-container" /> Jump to Comments </a> 
    

    would add the anchor to the existing URL