Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to clean up my blog by only displaying comments when a user specifically wants to - as in they click on the "view comments" URL.

I've formatting my posts normally, and at the end I have a link to display comments, using the comments_link() function. The comments_link() function seems to take the post and append a "/#comments" to the posts permalink URL.

What I would like to do is analyze the URL to see if the "/#comments" is in the URL, and if so then I would call my custom action to display the comments, otherwise I will post a comments_link asking the user if he wants to post the comment. If there is any other flag built into WP for determining whether the user clicked on the comments link, that would be preferable as well.

The only problem is, I'm not sure how to analyze the URL to determine if they clicked on the comments link. Any help is appreciated, thanks.

share|improve this question
    
Not 100% sure what you are looking to achieve but could be as simple as a PHP if stamement of sorts to check if the URL ends in /#comments then carry out the action. Sorry if this is no help but hopefully might point you in the right direction of the functionality you are looking for. –  Vince Pettit Jul 27 '11 at 11:37
    
the issue with checking the url with php is that anything after a hash tag gets stripped by the browser and isn't available. have a look at this question about rewriting the comments urls so they are on their own pages, that might work for you. –  Milo Jul 27 '11 at 13:53
add comment

closed as off topic by toscho Jul 6 '12 at 20:21

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. 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 reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.