WordPress.org

Forums

[resolved] How to create a direct links to a blog post sub headings? (5 posts)

  1. Bluemad
    Member
    Posted 2 years ago #

    Hello!

    I saw that some of the WordPress bloggers use direct links to a specific post sub heading. Once user click on that link, it automatically open that blog post and scroll down to the focused sub heading. How do I do it?

    Most of these links are just like this http://mydomain.com/mypost.html#

    If i put my subheading after the #, nothing happen, only open the blog post. :(

  2. Bluemad
    Member
    Posted 2 years ago #

    I saw this type of thing use Disqus, for instance. http://mydomain.com/mypost.html#comment-787684982

  3. WPyogi
    Forum Moderator
    Posted 2 years ago #

    Yes, that should be possible, but you have to have and use a valid id for the sub-heading being linked to. For example, in the link above, the comment being linked to would have this id in the HTML for that comment - something like:

    <div id="comment-787684982" .... >Comment here</div>

    So that will only work if your subheadings have id's or you assign them in the HTML of your content.

  4. Bluemad
    Member
    Posted 2 years ago #

    Friend, is this method correct?

    For instance I have a sub heading, it's How to use Google

    Then I added this type of thing to post text area.

    <div id="How to use Google">How to use Google</div>

    Is it OK?

  5. Bluemad
    Member
    Posted 2 years ago #

    Yes, it working. Thank you friend. :D

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.