Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For those who don't know, an example of a fragment identifier commonly used in a WordPress context is a link to a particular comment - wordpress/?p=34#comment-11.

The theme I am developing hides comments when you first view a post and allows you to view them using a custom content slider. When someone links to a comment however, because the comments are hidden, it won't scroll to the comment.

How do you detect if there is a fragment identifier in the URL?

share|improve this question
This seems like more of JavaScript/jQuery question and is probably better asked on StackOverflow – Joseph Jul 12 '12 at 12:18

closed as off topic by Rarst Jul 12 '12 at 12:41

Questions on WordPress Answers are expected to relate to WordPress within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

You can use jQuery for this:

(function($) {
    var hash = window.location.hash.split("#")[1];
    $("#" + hash).show(); // or slidedown or whatever
})(jQuery);
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.