WordPress Comments within Page or Post Body: Difference between revisions
Created page with "This article is about creating the capability of placing comments within the body of a page or post for WordPress. To be ''very'' clear, the "comment / comments" referred to..." |
mNo edit summary |
||
| Line 1: | Line 1: | ||
This article is about creating the capability of placing comments within the body of a page or post for WordPress. To be ''very'' clear, the "comment / comments" referred to here are ''not'' messages (AKA comments) from readers often viewed as "feedback". The "comments" referred to here are comments in the sense / context of "notes to self" within the body of a page or post. | This article is about creating the capability of placing comments within the body of a page or post for WordPress. To be ''very'' clear, the "comment / comments" referred to here are ''not'' messages (AKA comments) from readers often viewed as "feedback". The "comments" referred to here are comments in the sense / context of "notes to self" within the body of a page or post. | ||
Programmers have this capability to add such notes within their program without affecting the software. Examples of comments are below in terms of how these comments are inserted; | |||
* In many forms of BASIC: REM Anything after an REM command is a comment | |||
* HTML: <-- Anything in between the <-- (less than symbol and two dashes / hyphens) and --> (two dashes / hyphens and a greater than symbol) is a comment --> | |||
* Java: /* Anything in between /* (forward slash and asterisk) and */ (asterisk and forward slash) is a comment */ | |||
* ...and about a billion other examples: https://en.wikipedia.org/wiki/Comment_(computer_programming) | |||
Does WordPress have such a method to do this? Nope. | |||
Should it? Many think so. | |||
Is there a plugin for this? Not as of the end of 2020* *Notice that asterisk there... When searching for such a plugin, there are plugins that offer a "comment / comments" shortcode that can be inserted into the body of a post or page. But the catch is that those "comment / comments" shortcodes are for the a fore mentioned "comments" that are messages / feedback from readers. Not at all what is needed. | |||
Is there a solution? Yup. And it is described below. Full credit on the ideabecause the answer is sourced from here: https://wordpress.stackexchange.com/questions/346286/is-it-possible-to-comment-out-text-in-a-post?rq=1 | |||
== Solution == | |||
=== Objective === | |||
Add the capability to include comments within a page or post using simple shortcode that is equivalent to other commenting methods in programming languages such as HTML, Java, etc. | |||
=== End Solution === | |||
[Comment]Anything in between these shortcode items is not displayed to end readers or even include in the HTML output to a browser (IE, it is stripped out at the server level) [/Comment] | |||
=== How it is Implemented === | |||
Within the theme's ''function.php'' file (or the child theme's equivalent file) add this simple line of code: <code>add_shortcode( 'comment', '__return_empty_string' );</code> | |||
Another suggestion is sourced from here: https://stackoverflow.com/questions/3344270/is-it-possible-to-comment-out-html-code-in-a-wordpress-post and suggests a method to enable using HTML comment tags within a page or post. | |||