<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Archives | Kernix Web Design</title>
	<atom:link href="https://kernixwebdesign.com/category/website/code/feed/" rel="self" type="application/rss+xml" />
	<link>https://kernixwebdesign.com/category/website/code/</link>
	<description>Website Design and Development</description>
	<lastBuildDate>Sun, 12 May 2024 18:13:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>

<image>
	<url>https://kernixwebdesign.com/wp-content/uploads/2020/12/cropped-fav-icon3-32x32.png</url>
	<title>Code Archives | Kernix Web Design</title>
	<link>https://kernixwebdesign.com/category/website/code/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Learn JavaScript: String and Array Methods</title>
		<link>https://kernixwebdesign.com/website/learn-javascript-string-array-methods/</link>
		
		<dc:creator><![CDATA[Jim Kernicky]]></dc:creator>
		<pubDate>Fri, 27 May 2022 00:09:05 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Website]]></category>
		<category><![CDATA[array methods]]></category>
		<category><![CDATA[learning javascript]]></category>
		<category><![CDATA[string methods]]></category>
		<guid isPermaLink="false">https://kernixwebdesign.com/?p=20079</guid>

					<description><![CDATA[<p>When you first start to learn JavaScript you find that there are so many methods that it can be overwhelming. This article makes that process easier by covering the 7 methods and properties that are in common with JavaScript strings and arrays.</p>
<p>The post <a href="https://kernixwebdesign.com/website/learn-javascript-string-array-methods/">Learn JavaScript: String and Array Methods</a> appeared first on <a href="https://kernixwebdesign.com">Kernix Web Design</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The number of methods and properties that you need to know and remember to solve JavaScript problems and build apps can be intimidating. In learning JavaScript, I noticed that there were method names that are used by both strings and arrays.</p>
<p>In this article, I cover 7 methods that are used by both arrays and strings. Learn these 7 methods and you actually have learned 14 JavaScript methods. I also cover an additional 7 methods that use different method names for the same or opposite purpose.</p>
<h2>String and Array methods in common</h2>
<p>The easiest set of methods to learn is the methods that work for both arrays and strings. There are 5 methods that have the same name and same effect for both strings and arrays. There are also two &#8220;properties&#8221; in common to both strings and arrays.</p>
<h3>The string and array slice() method</h3>
<p>Use slice to return a copy or a portion of a string or array without mutating the original.</p>
<p>Use <code>str.<span class="purple">slice</span>()</code> to return a copy of the string.</p>
<p>Use <code>arr.<span class="purple">slice</span>()</code> to return a copy of the array.</p>
<p>Both methods can be used without any arguments, with a start index only, or with both a start and ending index. For more information on the methods check out MDN <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice">String Slice</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice">Array Slice</a> pages.</p>
<h3 class="western">The string and array concat() method</h3>
<p>The concat method concatenates, or merges, two or more strings or arrays together by adding the value in the parentheses to the end of the calling string/array. Check out MDN <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat">String concat</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat">Array concat</a> for more information.</p>
<p>Use <code>str.<span class="purple">concat</span>(str2, str3, …)</code> to join 2 or more strings and return a copy of the joined strings.</p>
<p>Use <code>arr.<span class="purple">concat</span>(arr2, arr3, …)</code> to join 2 or more arrays and return a copy of the joined arrays.</p>
<p><strong>NOTE</strong>: Using the <code>+</code> and <code>+=</code> assignment operators used with strings accomplishes the same effect as <code><span class="purple">concat</span>()</code>. It is strongly recommended to use the assignment operators instead of the <code><span class="purple">concat</span>()</code> method with strings.</p>
<h3>The string and array includes() method</h3>
<p>The includes method is extremely useful, especially as a condition in if statements. Take a look at MDN <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes">string includes</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes">array includes</a> for syntax and examples.</p>
<p>Use <code>str.<span class="purple">includes</span>(value)</code> to perform a case-sensitive search to determine whether one string may be found within another string, returning true or false as appropriate.</p>
<p>Use <code>arr.<span class="purple">includes</span>(value)</code> to determine whether an array includes a certain value among its entries, returns true or false.</p>
<h3>The string and array indexOf() method</h3>
<p>The indexOf method is also extremely useful for various purposes. Check out MDN <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf">string indexOf</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf">array indexOf</a> for more examples and syntax.</p>
<p>Use <code>str.<span class="purple">indexOf</span>(value)</code> to return the first index at which a given element can be found in the string, or -1 if it is not present.</p>
<p>Use <code>arr.<span class="purple">indexOf</span>(value)</code> to return the first index at which a given element can be found in the array, or -1 if it is not present.</p>
<h3>The string and array lastIndexOf() method</h3>
<p>The lastIndexOf method works as the indexOf method but searches starting at the end of the string or array. Check the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf">string lastIndexOf</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf">array lastIndexOf</a> methods on MDN.</p>
<p>Use <code>str.<span class="purple">lastIndexOf</span>(value)</code> to return the last index at which a given element can be found in the string, or -1 if it is not present.</p>
<p>Use <code>str.<span class="purple">lastIndexOf</span>(value)</code> to return the last index at which a given element can be found in the array, or -1 if it is not present.</p>
<h3>Two properties in common: length and bracket notation</h3>
<p>The following two techniques are not methods but are common to both strings and arrays. Both .length and bracket notation are very useful and you probably are already aware of them, but I wanted to include them all the same.</p>
<p>Use <code>str.<span class="blue">length</span></code> and <code>arr.<span class="blue">length</span></code> to return the length of the string and array respectively.</p>
<p>Use <code>str[index]</code> and <code>arr[index]</code> to return the string character and array value at the specified index respectively.</p>
<p>&nbsp;</p>
<p><img fetchpriority="high" decoding="async" class="alignleft wp-image-20094 size-full" src="https://kernixwebdesign.com/wp-content/uploads/2022/05/learning-javascript.jpg" alt="Confidence with programming" width="400" height="268" srcset="https://kernixwebdesign.com/wp-content/uploads/2022/05/learning-javascript.jpg 400w, https://kernixwebdesign.com/wp-content/uploads/2022/05/learning-javascript-300x201.jpg 300w" sizes="(max-width: 400px) 100vw, 400px" /></p>
<h2>String and Array methods with different names but with similarities</h2>
<p>Here are some other methods that have different names but have the same or opposite results. Personally, I do not use the first two methods and have only occasionally used the substring method.</p>
<h3>charAt and at methods</h3>
<p>Using str.charAt and arr.at returns the value at the index similar to bracket notation. There are reasons why you would use the arr.at() method over bracket notation (see <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at">MDN array at method</a>), but I fail to see the application for the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt">string charAt</a> method.</p>
<p>Use <code>str.<span class="purple">charAt</span>(index)</code> to return the character at the index.</p>
<p>Use <code>arr.<span class="purple">at</span>(index)</code> to return the array item at the index.</p>
<h3>Substring and splice (and slice) methods</h3>
<p>Splice, slice, and substring all extract a part of an array or string. Substring and slice are identical with the exception of edge cases.</p>
<p>Use <code>str.<span class="purple">substring</span>()</code> to return a part of a string.</p>
<p>Use <code>arr.<span class="purple">splice</span>()</code> to return part of an array.</p>
<p>Slice and substring do not mutate the original source, but arr.splice() does. Check out <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring">MDN substring</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice">array splice</a> pages for more information. You should use all 3 methods on strings and arrays where applicable to understand the differences.</p>
<h3>Split vs. Join methods</h3>
<p>The split method is fantastic when working with strings. I believe I have only used the array join method in conjunction with split.</p>
<p>Use <code>str.<span class="purple">split</span>()</code> to turn a string into an array of substrings.</p>
<p>Use <code>arr.<span class="purple">join</span>()</code> to turn an array into a string.</p>
<p><strong>NOTE</strong>: These two are often used in tandem. A common problem you will see is to turn a page or blog post title into a URL slug with a dash (-) as a separator. freeCodeCamp has an intermediate algorithm called <em>Spinal Tap</em> for that scenario but with some tricky test cases.</p>
<p>Check out the MDN pages on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split">string split</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join">array join</a> for more information.</p>
<h2>Final Thoughts</h2>
<p>Hopefully, comparing JavaScript string and array methods like this has made learning JavaScript a little easier.</p>
<p>There are a handful of other string methods you should learn, and a lot more array methods as well. Let this article start you on the road to improving your understanding of JavaScript.</p>
<p>I have a repository on Github called <a href="https://github.com/Kernix13/javascript-cheat-sheet">JavaScript Cheat Sheet</a> though it is way bigger than a cheat sheet, and is still a work-in-progress. Take a look at it and start building your own JavaScript cheat sheet to help you get coding better and faster!</p>
<p>The post <a href="https://kernixwebdesign.com/website/learn-javascript-string-array-methods/">Learn JavaScript: String and Array Methods</a> appeared first on <a href="https://kernixwebdesign.com">Kernix Web Design</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Markdown Cheat Sheet for Beginners</title>
		<link>https://kernixwebdesign.com/website/code/markdown-cheat-sheet-beginners/</link>
		
		<dc:creator><![CDATA[Jim Kernicky]]></dc:creator>
		<pubDate>Tue, 15 Feb 2022 22:52:54 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[github markdown cheat sheet]]></category>
		<category><![CDATA[markdown codeblock]]></category>
		<category><![CDATA[markdown syntax]]></category>
		<guid isPermaLink="false">https://kernixwebdesign.com/?p=20019</guid>

					<description><![CDATA[<p>You need to learn markdown if you have or contribute to repositories on websites like GitHub, or for forums and learning sites like freeCodeCamp. Specifically, you need it for creating and editing README and other documentation files. In this Markdown cheat sheet, I will show you the basic Markdown syntax . . .</p>
<p>The post <a href="https://kernixwebdesign.com/website/code/markdown-cheat-sheet-beginners/">Markdown Cheat Sheet for Beginners</a> appeared first on <a href="https://kernixwebdesign.com">Kernix Web Design</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>You need to learn markdown if you have or contribute to repositories on websites like GitHub, or for forums and learning sites like freeCodeCamp. Specifically, you need it for creating and editing README and other documentation files.</p>
<p>In this Markdown cheat sheet, I will show you the basic Markdown syntax to create your first README.md files followed by some intermediate and advanced syntax to make your repos look professional.</p>
<h2>Basic Markdown</h2>
<p>If you found this article then you already know what markdown is and that you need to learn it. I will not cover what it is, why you need it, who invented it, etc. Let’s get into it.</p>
<p>Below are some of the most common styling that you would want in your README files. Consider cloning or forking my <a href="https://github.com/Kernix13/markdown-cheatsheet" target="_blank" rel="noopener">markdown-cheatsheet repo on GitHub</a> to see examples of what you can do.</p>
<p>By the way, you can preview markdown in VS Code without an extension, although some markdown does not display such as footnotes. Look at the red arrow in the image below &#8211; just click on that. It helps to toggle the sidebar and been reduce the markdown file.</p>
<p><img decoding="async" class="aligncenter wp-image-20057 size-full" src="https://kernixwebdesign.com/wp-content/uploads/2022/02/markdown-preview-lg.png" alt="Markdown preview button" width="600" height="372" srcset="https://kernixwebdesign.com/wp-content/uploads/2022/02/markdown-preview-lg.png 600w, https://kernixwebdesign.com/wp-content/uploads/2022/02/markdown-preview-lg-300x186.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<h3>Headings and paragraphs</h3>
<p>Paragraphs are just regular text with 2 line breaks needed between each paragraph and other elements.</p>
<p>There are 6 heading sizes in markdown like there is in HTML, though I never use h5 or h6 for my pages. You just use 1 through 6 hashtags for heading1 through heading6.</p>
<p><strong>NOTE</strong>: There is an automatic horizontal rule added when you use syntax for H1 and H2.</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1"><span class="blue"># Heading1</span></code> <code data-line="2"><span class="blue">## Heading2</span></code> <code data-line="3"><span class="blue">### Heading3</span></code></pre>
</div>
<h3>Blockquotes</h3>
<p>This would be useful to quote someone you are contributing with. Use a greater than sign (&gt;) to show a blockquote. Use 2 for nested blockquote but who does that?</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="5"><span class="green">&gt; This is a quote</span></code> <code data-line="6"><span class="green">&gt;</span></code> <code data-line="7"><span class="green">&gt; Try an empty line like above</span></code> <code data-line="8"><span class="green">&gt;</span></code> <code data-line="9"><span class="green">&gt; &gt; Or use a nested blockquote</span></code></pre>
</div>
<h3>Bold text</h3>
<p>Use either 2 asterisks or 2 underscores before and after the text for bold styling. The preferred syntax is to use asterisks for bold: **<strong>bold text</strong>** or __<strong>bold text</strong>__.</p>
<h3>Italic text</h3>
<p>Use a single asterisk or underscore before and after text to display it as italic. The preferred syntax is to use an underscore for italic: *<em>This is italic text</em>* and _<em>So is this</em>_.</p>
<h3>Bold &amp; italic text</h3>
<p>Use either 3 asterisks before and after the word(s) or 2 asterisks and an underscore:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="11">***This is bold and italic text***</code> <code data-line="12">**_This is ALSO bold and italic text_**</code></pre>
</div>
<h3>Strikethrough text</h3>
<p>Use two tildes (~~) before and after the text you want to display as <del>strikethrough</del>. I have never used strikethrough but maybe you do:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="13">~~Strikethrough text~~</code></pre>
</div>
<h3>Horizontal rules</h3>
<p>The way I prefer to make a horizontal rule is with 3 dashes with a space between them, but you could use 3 dashes without a space or 3 asterisks with or without spaces:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="20"><span class="blue">- - -</span></code> <code data-line="21"><span class="blue">---</span></code> <code data-line="22"><span class="blue">* * *</span></code> <code data-line="23"><span class="blue">***</span></code></pre>
</div>
<p><strong>NOTE</strong>: Make sure to hit <em>ENTER</em> twice if you intend to use 3 asterisks without spaces or it will set the text above it to an H3 tag.</p>
<hr />
<h3>Inline Code</h3>
<p>You can use code in a sentence and highlight it by using a single backtick before and after the code such as <span class="inline-code">&lt;div class=&#8221;row&#8221;&gt;</span>:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1"><span class="blue">`&lt;div class="row"&gt;`</span></code></pre>
</div>
<h3>Code blocks</h3>
<p>For multi-line code blocks use 3 backticks before and after the code block:</p>
<div class="pre-container">
<pre class="code-block dark_block">        ```
        pre span {
          display: inline-block;
        }
        ```
</pre>
</div>
<h3>External Links</h3>
<p>Links have 2 parts to them with an optional parameter. The link text goes between square brackets [ ], and the URL goes inside parentheses ( ). You can also add a title for the link that will display when a user hovers over the link. To do that you would and a space after the URL and then inside a set of double-quotes add a link title:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1">[<span class="light-blue">Kernix Web Design</span>](https://kernixwebdesign.com <span class="light-blue">'Home page'</span>)</code></pre>
</div>
<h3>Anchor links</h3>
<p>By &#8220;anchor&#8221; links, I mean links that go to a section of the page as opposed to another page or website.</p>
<p>This can be done in at least two different ways. For all the links in the table of contents in my repo (see link at top), I use the <em>easy</em> method. But for the <strong>Back to Top</strong> link, I use an actual &lt;a&gt; tag.</p>
<p>You need to use the same syntax of square brackets and parentheses for links with both methods: [Link text](URL).</p>
<p>The first method is to add an empty &lt;a&gt; tag with an id attribute that matches the hashed URL link:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1">&lt;<span class="green">a</span> <span class="blue">name</span>=<span class="light-blue">"top_anchor"</span>&gt;&lt;/<span class="green">a</span>&gt;</code> <code data-line="2">[<span class="light-blue">Back To Top</span>](#top_anchor)</code></pre>
</div>
<p>The second method is more common especially for table of contents links in README files. You put the exact text that you want to link to in the square brackets with the same case. In the parentheses you start with a hash symbol followed by the exact text all in lowercase and connected with dashes:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1">[<span class="light-blue">Exact words in target link</span>](#exact-words-in-target-link)</code></pre>
</div>
<h3>Images</h3>
<p>The syntax for an image is identical for a link with the exception of adding an exclamation mark (!) before the opening square bracket. Also, replace the link text with alt text:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1">![<span class="light-blue">alt text</span>](https://via.placeholder.com/150)</code></pre>
</div>
<h3>Lists</h3>
<p>You can use either an asterisk or a dash followed by a space to make a bulleted list. I prefer using a dash since you do not need to use the <em>SHIFT</em> key. For nested lists, use the <em>SPACEBAR</em> key to align directly beneath the first character in the parent list item to create a nested list:</p>
<div class="pre-container">
<pre class="code-block dark_block">    <span class="orange">-</span> List item one
    <span class="orange">-</span> List item two
      <span class="orange">-</span> Child item one
</pre>
</div>
<p>Use a number followed by a period (1., 2., 3. etc.) to create an ordered list. For a nested ordered list, do the same as for nested unordered lists &#8211; align the number to be below the first character of the parent item.</p>
<div class="pre-container">
<pre class="code-block dark_block">    <span class="orange">1.</span> List item one
    <span class="orange">1.</span> List item two
        <span class="orange">1.</span> Child item one
</pre>
</div>
<p><strong>NOTE</strong>: By using &#8220;1&#8221; for each list item, you can cut &amp; paste to change the order of items and the numbering will change to match the new order.</p>
<h2>More advanced Markdown</h2>
<p>Use the following markdown syntax for “fancy pants” markdown files.</p>
<h3>Code blocks with code highlighting</h3>
<p>A really nice feature for code blocks is to have basic syntax highlighting by adding the language after the first set of triple backticks. Here are the languages I have tested but check out my repo for examples: <span class="inline-code">md</span>, <span class="inline-code">html</span>, <span class="inline-code">css</span>, <span class="inline-code">js</span>, <span class="inline-code">json</span>, <span class="inline-code">php</span>, <span class="inline-code">sql</span>, <span class="inline-code">xml</span>, <span class="inline-code">svg</span>, <span class="inline-code">python</span>, <span class="inline-code">apacheconf</span>, …</p>
<div class="pre-container">
<pre class="code-block dark_block">```css
    <code data-line="1"><span class="green">pre</span> <span class="green">span</span> {</code> <code data-line="2"> <span class="blue">display</span>: inline-block;</code> <code data-line="3">}</code> ```</pre>
</div>
<p>I did not create any CSS to show you the styling for most of the fancier markdown features so check the repo to see what it looks like.</p>
<h3>Diff code blocks</h3>
<p>These are really nice for highlighting changed values and the new values. Use diff after the opening triple backticks, then a minus sign (-) and space for what was changed, and a positive sign (+) and a space for the new text/code.</p>
<div class="pre-container">
<pre class="code-block dark_block"><code>```diff</code> <code><span class="red">- this code or text is the old version</span></code> <code><span class="green">+ this is what it was changed to</span></code> <code>```</code></pre>
</div>
<h3>Comments</h3>
<p>This is a nice way to add a comment in the editor view of your markdown file. This would be good for teams members editing a documentation page for a new section. The best way is to use HTML syntax:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1"><span class="comment">&lt;!-- HTML comments work best IMO --&gt;</span></code></pre>
</div>
<h3>Tasks</h3>
<p>You can create what looks like checkboxes and display completed tasks with a checkmark. It takes the form of an unordered list with the first characters being a set of square brackets [ ] which MUST have a space in them. For a completed task, add either a lower or uppercase &#8220;X&#8221; inside the square brackets [x].</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1"><span class="orange">-</span> [ ] incomplete task</code> <code data-line="2"><span class="orange">-</span> [<span class="light-blue">x</span>] completed task</code> <code data-line="3"> <span class="orange">-</span> [ ] incomplete subtask</code> <code data-line="4"> <span class="orange">-</span> [<span class="light-blue">x</span>] completed subtask</code></pre>
</div>
<h3>Tables</h3>
<p>I only used this for the Pull Requests and Issues I opened on freeCodeCamp. That table is a list of common prefixes to include in your titles (check out my <a href="https://github.com/Kernix13/beginner-git-commands" target="_blank" rel="noopener">Beginner Git Commands repo</a>). Here is a generic table.</p>
<p>Pay attention to the syntax that is creating the column divisions and alignment. The pipes create the columns and the colons determine the alignment.</p>
<div class="pre-container">
<pre class="code-block dark_block">    | Left aligned | Center aligned | Right aligned |
    | :----------- | :------------: | ------------: |
    | Content Left | Content Center | Content Right |
    | Content Left | Content Center | Content Right |
    | Content Left | Content Center | Content Right |
    | Content Left | Content Center | Content Right |
</pre>
</div>
<h3>Footnotes</h3>
<p>I assume footnotes would be useful in a very technical or long README file. Use square brackets where you want a footnote link to appear and use a caret symbol (^) followed by the number of the footnote. Then below that area add the same syntax followed by a colon and the note itself. That will make the footnote text appear at the bottom of your file.</p>
<p>Here is what your text with the footnote syntax will look like:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="1">Footnote.[<span class="light-blue">^1</span>]</code> <code data-line="2">Another footnote.[<span class="light-blue">^2</span>]</code></pre>
</div>
<p>Here is the syntax for the actual footnote:</p>
<div class="pre-container">
<pre class="code-block dark_block"><code data-line="4">[<span class="light-blue">^1</span>]: This is footnote number one.</code> <code data-line="5">[<span class="light-blue">^2</span>]: Here is the second footnote.</code></pre>
</div>
<h2>Final Thoughts</h2>
<p>There is a lot more you can do with your markdown files like actually using HTML tags. I have seen &lt;a&gt;, &lt;p&gt; and &lt;span&gt; tags in profile MD files, but I have not done much research into what you can and cannot use. I have also seen videos in markdown files so that would be something to look into for your GitHub profile.</p>
<p>Also note that all the syntax can be used in Discord and Slack, though slack has editor buttons for them, whereas Discord does not. I also see markdown used in forums and support tickets for some websites and hosting companies.</p>
<p>Here are some additional links that you can use to build your own Markdown cheat sheet:</p>
<ol>
<li><a href="https://daringfireball.net/projects/markdown/">Daring Fireball</a>: Check out the Markdown Basics and Syntax tabs.</li>
<li><a href="https://dev.to/nikolab/complete-list-of-github-markdown-emoji-markup-5aia">Complete list of github markdown emojis</a></li>
<li><a href="https://gist.github.com/rxaviers/7360908">GitHub emoji list</a></li>
</ol>
<p>Here is a markdown cheat sheet in table version (basic code only):</p>
<table>
<thead>
<tr>
<th>Format</th>
<th>Syntax</th>
</tr>
</thead>
<tbody>
<tr>
<td>H1</td>
<td>#</td>
</tr>
<tr>
<td>H2</td>
<td>##</td>
</tr>
<tr>
<td>H3</td>
<td>###</td>
</tr>
<tr>
<td>H4</td>
<td>####</td>
</tr>
<tr>
<td>Italics</td>
<td>*italics*</td>
</tr>
<tr>
<td>Bold</td>
<td>**Bold**</td>
</tr>
<tr>
<td>Strike thru</td>
<td>~~strikethrough~~</td>
</tr>
<tr>
<td>Horiz. Rule</td>
<td>&#8211; &#8211; &#8211;</td>
</tr>
<tr>
<td>Block quote</td>
<td>&gt; text here</td>
</tr>
<tr>
<td>Links</td>
<td>[link text](domain.com)</td>
</tr>
<tr>
<td>Anchor link</td>
<td>[Exact text](#exact-text)</td>
</tr>
<tr>
<td>Footnote link</td>
<td>[^1]</td>
</tr>
<tr>
<td>Footnote text</td>
<td>[^1]: text here</td>
</tr>
<tr>
<td>Image</td>
<td>![alt text](domain.com)</td>
</tr>
<tr>
<td>Comment</td>
<td>&lt;!&#8211; comment &#8211;&gt;</td>
</tr>
<tr>
<td>Unordered list</td>
<td>&#8211; List item * List item</td>
</tr>
<tr>
<td>Inline Code</td>
<td>`insert code here`</td>
</tr>
<tr>
<td>Code block</td>
<td>3 backticks</td>
</tr>
</tbody>
</table>
<p>The post <a href="https://kernixwebdesign.com/website/code/markdown-cheat-sheet-beginners/">Markdown Cheat Sheet for Beginners</a> appeared first on <a href="https://kernixwebdesign.com">Kernix Web Design</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress Recent Posts using a Custom Query</title>
		<link>https://kernixwebdesign.com/website/code/wordpress-recent-posts-using-a-custom-query/</link>
		
		<dc:creator><![CDATA[Jim Kernicky]]></dc:creator>
		<pubDate>Sat, 30 Jan 2021 02:04:39 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[get_posts]]></category>
		<category><![CDATA[wordpress recent posts]]></category>
		<category><![CDATA[wp_query example]]></category>
		<guid isPermaLink="false">https://kernixwebdesign.com/?p=366</guid>

					<description><![CDATA[<p>I prefer to do as much as I can in WordPress without using a plugin. A simple thing is to write a WordPress custom query to display the 3 most recent posts in a category or other criteria. I show the code I used to generate the 3 most recent posts using 2 different custom queries.</p>
<p>The post <a href="https://kernixwebdesign.com/website/code/wordpress-recent-posts-using-a-custom-query/">WordPress Recent Posts using a Custom Query</a> appeared first on <a href="https://kernixwebdesign.com">Kernix Web Design</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>You can use a custom query in WordPress to retrieve any data that is in the database. Using get_posts and WP_Query are 2 easy custom queries you can write to pull data out of the WordPress database. I show the code I used to generate the recent posts on this website &#8211; without a plugin!</p>
<h2>WordPress recent posts using custom queries</h2>
<p>The two methods I found best to display the 3 most recent posts were to use get_posts and WP_Query.</p>
<p>Here is a custom query using WP_Query. You can use this custom query inside or outside of the loop. The first code block calls WP_Query and 3 posts in the code category while excluding sticky posts. It also selects &#8216;posts&#8217; post types as opposed to pages or custom post types, but you could choose those as well.</p>
<p>You can query on any database field that you need. For me, I wanted to display the 3 most recent published posts in my Code Snippets category.</p>
<p>Lines 10-12 uses the new instance of WP_Query ($query) to query the specific posts from the database.</p>
<div class="pre-container">
<pre class="code-block dark_block">
        <code data-line="1">&lt;<span class="green">?php</span></code>
        <code data-line="2"></code>
        <code
          data-line="3"> $query <span class="blue"></span>= <span class="red">new</span> <span class="purple">WP_Query</span>( [</code>
          <code
            data-line="4"> <span class="light-blue">&apos;post__not_in&apos;</span> <span class="blue"></span>=&gt; <span class="purple">get_option</span>( <span class="light-blue">&apos;sticky_posts&apos;</span>),</code>
          <code
            data-line="5"> <span class="light-blue">&apos;post_type&apos;</span> <span class="blue"></span>=&gt; <span class="light-blue">&apos;post&apos;</span>,</code>
          <code
            data-line="6"> <span class="light-blue">&apos;post_status&apos;</span> <span class="blue"></span>=&gt; <span class="light-blue">&apos;publish&apos;</span>,</code>
          <code
            data-line="7"> <span class="light-blue">&apos;category_name&apos;</span> <span class="blue"></span>=&gt; <span class="light-blue">&apos;code&apos;</span>,</code>
          <code
            data-line="8"> <span class="light-blue">&apos;posts_per_page&apos;</span> <span class="blue"></span>=&gt; 3,</code>
        <code data-line="9"> ] );</code>
        <code data-line="10"></code>
        <code data-line="11"> <span class="red">if</span> ($query-&gt;<span class="purple">have_posts</span>())<span class="orange"></span> {</code>
          <code
            data-line="12"> <span class="red">while</span> ($query-&gt;<span class="purple">have_posts</span>())<span class="orange"></span> {</code>
            <code data-line="13"> $query-&gt;<span class="purple">the_post</span>(); <span class="green">?</span>&gt;</code>
      </pre>
</p></div>
<p>The code block below is the HTML for the post details along with some necessary PHP functions. Since WP_Query works both inside and outside of the loop, you&#8217;ll need to decide if it&#8217;s best used in the loop or outside of it.</p>
<p>Don&#8217;t forget to use wp_reset_postdata or it may mess up the page below the query or break the page.</p>
<div class="pre-container">
<pre class="code-block dark_block">
        <code
          data-line="1">&lt;<span class="green">div</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;recent-row&quot;</span>&gt;</code>
          <code data-line="2"> &lt;<span class="green">?php</span> <span class="purple">the_post_thumbnail</span>() ?&gt;</code>
          <code
            data-line="3"> &lt;<span class="green">a</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;recent-posts-link&quot;</span> <span class="blue">href</span><span class="blue"></span>=&quot;&lt;<span class="green">?php</span> <span class="purple">the_permalink</span>(); <span class="green">?</span>&gt;&quot; </code>
          <code
            data-line="4"> <span class="blue">rel</span><span class="blue"></span>=<span class="light-blue">&quot;bookmark&quot;</span>&gt;&lt;<span class="green">h4</span>&gt;&lt;<span class="green">?php</span> <span class="purple">the_title</span>(); ?&gt;&lt;<span class="green"></span>/<span class="green">h4</span>&gt;&lt;<span class="green"></span>/<span class="green">a</span>&gt;</code>
      
          <code
            data-line="6"> &lt;<span class="green">?php</span> <span class="purple">get_template_part</span>( <span class="light-blue">&apos;template-parts/content&apos;</span>, <span class="light-blue">&apos;author&apos;</span> ); <span class="green">?</span>&gt;</code>
      
           <code
             data-line="8">&lt;<span class="green">?php</span> <span class="purple">the_excerpt</span>(); <span class="green">?</span>&gt;</code>
          <code
            data-line="9"> &lt;<span class="green">div</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;recent-post-widget&quot;</span>&gt;&lt;<span class="green"></span>/<span class="green">div</span>&gt;</code>
          <code
            data-line="10"> &lt;<span class="green">a</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;recent-posts-button&quot;</span> <span class="blue">href</span><span class="blue"></span>=&quot;&lt;<span class="green">?php</span> <span class="purple">the_permalink</span>(); ?&gt;&quot;&gt;</code>
          <code data-line="11"> Read more...&lt;<span class="green"></span>/<span class="green">a</span>&gt;</code><code data-line="12"> &lt;<span class="green">?php</span></code>
          <code data-line="13"> }</code>
        <code data-line="14"> }</code>
        <code data-line="15"> <span class="purple">wp_reset_postdata</span>();</code>
        <code data-line="16"> ?&gt;</code>
      </pre>
</p></div>
<p>However, if you are on a page that has the loop, then you might as well take advantage of the post data. The loop is fetching the database fields for $post, so use either WP_Query or a get_posts() query while in the loop.</p>
<p>The get_posts query does not work unless it is inside the loop. Here is the code for get posts that returns the same data as WP_Query.</p>
<div class="pre-container">
<pre class="code-block dark_block">
        <code data-line="1"><span class="red">if</span> ( <span class="purple">have_posts</span>() ) :</code>
        <code data-line="2"> <span class="red">while</span> ( <span class="purple">have_posts</span>() ) :</code>
        <code data-line="3"> <span class="purple">the_post</span>();</code>
          <code
            data-line="4"> <span class="purple">get_template_part</span>( <span class="light-blue">&apos;template-parts/content&apos;</span>, <span class="light-blue">&apos;front-page&apos;</span> ); <span class="green">?</span>&gt;</code>
      
        <code
          data-line="6"> &lt;<span class="green">aside</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;bgcolor4&quot;</span>&gt;&lt;<span class="green"></span>/<span class="green">aside</span>&gt;</code>
          <code
            data-line="7"> &lt;<span class="green">div</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;container&quot;</span>&gt;&lt;<span class="green"></span>/<span class="green">div</span>&gt;</code>
          <code
            data-line="8"> &lt;<span class="green">h3</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;custom-title&quot;</span>&gt;</code>
            <code
              data-line="9"> &lt;<span class="green">?php</span> <span class="purple">esc_html_e</span>(<span class="light-blue">&apos;Latest Articles &apos;</span>, <span class="light-blue">&apos;tower&apos;</span>) <span class="green">?</span>&gt;</code>
          <code data-line="10"> &lt;<span class="green"></span>/<span class="green">h3</span>&gt;</code>
          <code
            data-line="11"> &lt;<span class="green">div</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;row&quot;</span>&gt;&lt;<span class="green"></span>/<span class="green">div</span>&gt;</code>
          <code data-line="12"> &lt;<span class="green">?php</span></code>
            <code data-line="13"> $posts <span class="blue"></span>= <span class="purple">get_posts</span>([</code>
              <code
                data-line="14"> <span class="light-blue">&apos;post_type&apos;</span> <span class="blue"></span>=&gt; <span class="light-blue">&apos;post&apos;</span>,</code>
              <code
                data-line="15"> <span class="light-blue">&apos;category_name&apos;</span> <span class="blue"></span>=&gt; <span class="light-blue">&apos;code&apos;</span>,</code>
              <code
                data-line="16"> <span class="light-blue">&apos;posts_per_page&apos;</span> <span class="blue"></span>=&gt; 3,</code>
            <code data-line="17"> ]);</code>
        <code data-line="18"></code>
        <code data-line="19"> <span class="red">foreach</span> ($posts as $post)<span class="orange"></span> {</code>
          <code data-line="20"> <span class="purple">setup_postdata</span>($post); <span class="green">?</span>&gt;</code>
        <code data-line="21"></code>
          <code
            data-line="22"> &lt;<span class="green">div</span> <span class="blue">class</span><span class="blue"></span>=<span class="light-blue">&quot;recent-row&quot;</span>&gt;</code>
      </pre>
</p></div>
<p>Lines 6-9 are the HTML elements and classes to be output for the container of the posts, then the custom get_posts query starts on line 10 and continues to line 18. You should notice the div.recent-row which starts the HTML in the code block above for WP_Query.</p>
<h2>Final thoughts</h2>
<p>Using a custom query to pull the most recent posts is best done in a plugin. I put mine directly into my template files since it&#8217;s my theme and my website, though I will be creating a plugin for the recent posts (look for that article).</p>
<p>There are a number of different parameters you can query other than the ones I used (post_type, category_name, posts_per_page). Go to the <a href="https://developer.wordpress.org/reference/classes/wp_query/#parameters">WP_Query developer&#8217;s page</a> to see other parameters you can use.</p>
<p>The post <a href="https://kernixwebdesign.com/website/code/wordpress-recent-posts-using-a-custom-query/">WordPress Recent Posts using a Custom Query</a> appeared first on <a href="https://kernixwebdesign.com">Kernix Web Design</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
