Struggling to give WordPress comments their own page without messing up your URL structure? I know the feeling.
Displaying a post’s comments separately from the main content can be useful in many circumstances. Although less common nowadays, traditionally many blogs chose to feature comments in a pop-up window or lightbox. It can also be desirable for editorial or legal reasons, for caching purposes, or perhaps if you are publishing individually art-directed posts. It can also be handy when using WordPress for a non-blog website.
WordPress has some legacy support for pop-up comments, but the feature is largely abandoned and poorly supported. Also, it generates the comments pages at
yoursite.com/?comments_popup=XXXX, which is both bad for SEO and will often appear in analytics as one page.
To solve this conundrum, I’ve created a basic plugin for developers to implement separate comments pages for their WordPress site. The plugin generates a comments page for each post at /comments/, using the WordPress rewrite endpoints API. It’s not quite install-and-go, so check out the notes below.
- You will need to customise the generated page by copying the included comments-single.php template into your theme; if you’re using this as a pop-up you will want to remove the
- WordPress doesn’t provide a filter hook for
comments_link(), so you’ll need to manually replace links to your comments to point to the new page at /comments/
- A current limitation is that it doesn’t play well with comment pagination.