Question

In programming, there is usually a way to "comment out" lines of text. Text that has been commented out does not compile and in no way affects the software. It's used for several different purposes, but most often either for having pieces of code that you're testing changes to or for leaving notes to other people RE: what specific sections of your code do.

Is there a way, natively in WordPress or through a plug-in, to introduce this functionality? Say, if you're collaborating on a post with another person and you want to leave a note for them that, if it's missed, won't be visible if the post is uploaded before said note can be removed.

I've tried looking for this myself, but every time I look for "wordpress" and "comments", the results are always in reference to the comments at the end of a published post.

Was it helpful?

Solution

There may be plugins that supply some kind of commenting functionality, similar to how Google Docs allows you to annotate parts of a document.

Within WordPress directly, you could use the "Text Editor" view and HTML comments. The downside here is that the HTML comments will be visible if someone goes to the page and uses their browser's "View Source" option which shows the unrendered HTML.

An example of post content with comments would be

<!-- No one can see this when the page is rendered -->
Some regular content in the WordPress editor.

An alternate method:

Define a custom shortcode that doesn't render.

You could create a custom shortcode that doesn't output anything. So, in your editor you'd have:

[comment]This content will not render to the post[/comment]

And then in your functions.php or somewhere else, add the following code:

add_shortcode( 'comment', '__return_empty_string' );

Then, whenever the shortcode is processed in the content, it will just return an empty string.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top