<?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>Technology &#8211; Gravyware&#039;s Blog</title>
	<atom:link href="https://blog.gravyware.com/category/technology/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.gravyware.com</link>
	<description>The best tech and startup info updated daily</description>
	<lastBuildDate>Tue, 21 Apr 2026 21:01:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.gravyware.com/wp-content/uploads/2023/01/apple-touch-icon-150x150.png</url>
	<title>Technology &#8211; Gravyware&#039;s Blog</title>
	<link>https://blog.gravyware.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Create a Page With a Custom URL in WordPress</title>
		<link>https://blog.gravyware.com/hobart/custom-page-url-in-wordpress</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Thu, 29 Aug 2024 20:47:12 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=3467</guid>

					<description><![CDATA[As a WordPress developer, you may often encounter situations where you need to create a page with a custom URL in WordPress for your theme.]]></description>
										<content:encoded><![CDATA[
<p>As a WordPress developer, some things are not straightforward. You may often encounter situations where you need to create a page with a custom URL in WordPress for your theme.</p>



<p>An example would be for a user profile page where the URL includes the <strong>user_nicename</strong> value instead of a user_id?</p>



<p>Let&#8217;s walk through the process of creating a custom page URL like <strong>https://xyz.com/user/johndoe</strong>, where &#8220;johndoe&#8221; is the user&#8217;s user_nicename value. This can be particularly useful for user profile pages or custom post types.</p>



<h2 class="wp-block-heading">Step 1: Add a Custom Rewrite Rule</h2>



<p>First, we need to add a custom rewrite rule to WordPress. This rule will tell WordPress how to handle our custom URL structure. Add the following code to your theme&#8217;s <strong>functions.php</strong> file:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function add_custom_rewrite_rule() {
    add_rewrite_rule('^user/(&#91;^/&#93;*)/?','index.php?pagename=user&amp;user=$matches&#91;1&#93;', 'top');
    add_rewrite_tag('%user%', '(&#91;^&amp;&#93;+)');
}
add_action('init', 'add_custom_rewrite_rule', 10, 0);</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">add_custom_rewrite_rule</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EA9A97">add_rewrite_rule</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;^user/(&#91;^/&#93;*)/?&#39;</span><span style="color: #908CAA">,</span><span style="color: #F6C177">&#39;index.php?pagename=user&amp;user=$matches&#91;1&#93;&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;top&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EA9A97">add_rewrite_tag</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;%user%&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;(&#91;^&amp;&#93;+)&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #EA9A97">add_action</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;init&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;add_custom_rewrite_rule&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">10</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">0</span><span style="color: #908CAA">);</span></span></code></pre></div>



<p>This rule tells WordPress to match URLs like <strong>/user/johndoe</strong> and internally rewrite them to <strong>index.php?pagename=user-profile&amp;user_slug=johndoe</strong>.</p>



<h2 class="wp-block-heading">Step 2: Add Custom Query Vars</h2>



<p>Next, we need to tell WordPress about our custom query variable user_slug. Add this code to your <strong>functions.php</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function add_custom_query_vars($query_vars) {
    $query_vars[] = 'user';
    return $query_vars;
}
add_filter('query_vars', 'add_custom_query_vars');</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">add_custom_query_vars</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">query_vars</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">query_vars</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;user&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">query_vars</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #EA9A97">add_filter</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;query_vars&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;add_custom_query_vars&#39;</span><span style="color: #908CAA">);</span></span></code></pre></div>



<h2 class="wp-block-heading">Step 3: Create a Custom Page Template</h2>



<p>Now, create a new file in your theme directory called <strong>page-user-profile.php</strong>. This will be the template for your user profile pages. Here&#8217;s a basic example:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;?php
/*
Template Name: User Profile
*/

get_header();

$user_slug = get_query_var('user');
$user = get_user_by('slug', $user_slug);

if ($user) {
    // Display user profile information
    echo '&lt;h1>' . esc_html($user->display_name) . '&lt;/h1>';
    echo '&lt;p>Email: ' . esc_html($user->user_email) . '&lt;/p>';
    // Add more user information as needed
} else {
    echo '&lt;p>User not found.&lt;/p>';
}

get_footer();</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">&lt;?php</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">/*</span></span>
<span class="line"><span style="color: #6E6A86; font-style: italic">Template Name: User Profile</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">*/</span></span>
<span class="line"></span>
<span class="line"><span style="color: #EA9A97">get_header</span><span style="color: #908CAA">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user_slug</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">get_query_var</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;user&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">get_user_by</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;slug&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user_slug</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Display user profile information</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;h1&gt;&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">esc_html</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user</span><span style="color: #3E8FB0">-&gt;</span><span style="color: #E0DEF4; font-style: italic">display_name</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;/h1&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;p&gt;Email: &#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">esc_html</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user</span><span style="color: #3E8FB0">-&gt;</span><span style="color: #E0DEF4; font-style: italic">user_email</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;/p&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Add more user information as needed</span></span>
<span class="line"><span style="color: #908CAA">}</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">else</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;p&gt;User not found.&lt;/p&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #EA9A97">get_footer</span><span style="color: #908CAA">();</span></span></code></pre></div>



<h2 class="wp-block-heading">Step 4: Create a WordPress Page</h2>



<p>In the WordPress admin panel, create a new page and title it &#8220;User Profile&#8221;. Set the template to the new page you just uploaded, and set the permalink value to &#8220;<strong>user</strong>&#8220;. This page won&#8217;t be directly accessible, but it&#8217;s necessary for our rewrite rule to work.</p>



<h2 class="wp-block-heading">Step 5: Flush Rewrite Rules</h2>



<p>After making these changes, you need to flush the rewrite rules. You can do this by going to <strong>Settings &gt; Permalinks</strong> in the WordPress admin panel and clicking &#8220;Save Changes&#8221; without making any changes.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="800" height="533" src="https://blog.gravyware.com/wp-content/uploads/2024/08/wordpress-typed-on-typewriter.jpg" alt="custom url in wordpress - wordpress typed on a typewriter" class="wp-image-3476" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/wordpress-typed-on-typewriter.jpg 800w, https://blog.gravyware.com/wp-content/uploads/2024/08/wordpress-typed-on-typewriter-300x200.jpg 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/wordpress-typed-on-typewriter-768x512.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<h2 class="wp-block-heading">Step 6: Link to User Profiles</h2>



<p>Now you can link to user profiles using the custom URL structure. For example:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>$user = get_user_by('id', 1);

$profile_url = home_url("/user/{$user->user_nicename}/");

echo '&lt;a href="' . esc_url($profile_url) . '">View Profile&lt;/a>';</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">get_user_by</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;id&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">1</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">profile_url</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">home_url</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;/user/</span><span style="color: #908CAA">{</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">user</span><span style="color: #3E8FB0">-&gt;</span><span style="color: #E0DEF4; font-style: italic">user_nicename</span><span style="color: #908CAA">}</span><span style="color: #F6C177">/&quot;</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;a href=&quot;&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">esc_url</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">profile_url</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&quot;&gt;View Profile&lt;/a&gt;&#39;</span><span style="color: #908CAA">;</span></span></code></pre></div>



<p>This should create a link to whichever user has a user ID value of &#8220;1&#8221;.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Congrats! You&#8217;ve successfully created a custom page URL structure for user profiles in WordPress. This technique can be adapted for other custom URL structures as well, such as for custom post types or other specialized pages.</p>



<p>Remember to always sanitize and escape data when working with user input and URLs to ensure the security of your WordPress site.</p>



<p>Good luck!</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Validate and Sanitize WordPress Secure Form Inputs</title>
		<link>https://blog.gravyware.com/validate-and-sanitize-wordpress-secure-form</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Mon, 19 Aug 2024 00:43:59 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=3450</guid>

					<description><![CDATA[Are you ready to dive into the world of WordPress secure form handling? Let's journey through the land of validation and sanitization!]]></description>
										<content:encoded><![CDATA[
<p>Are you ready to dive into the world of WordPress secure form handling? Buckle up, because we&#8217;re about to embark on an exciting journey through the land of validation and sanitization! </p>



<div class="wp-block-rank-math-toc-block has-theme-palette-7-background-color has-background" style="padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--40)" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#the-shocking-truth-about-word-press-secure-form-security">The Shocking Truth About WordPress Secure Form Security</a></li><li><a href="#why-should-you-care-about-input-validation-and-sanitization">Why Should You Care About Input Validation and Sanitization?</a><ul><li><a href="#the-dynamic-duo-of-form-security">The Dynamic Duo of Form Security</a></li><li><a href="#the-risks-of-skipping-security">The Risks of Skipping Security</a></li></ul></li><li><a href="#setting-up-your-word-press-form-handling-fortress">Setting Up Your WordPress Form-Handling Fortress</a><ul><li><a href="#the-tools-of-the-trade">The Tools of the Trade</a></li><li><a href="#creating-your-custom-form-handling-plugin">Creating Your Custom Form-Handling Plugin</a></li></ul></li><li><a href="#basic-php-validation-techniques-your-first-line-of-defense">Basic PHP Validation Techniques: Your First Line of Defense</a><ul><li><a href="#the-power-of-ph-ps-built-in-functions">The Power of PHP&#8217;s Built-in Functions</a></li><li><a href="#crafting-custom-validation-rules">Crafting Custom Validation Rules</a></li></ul></li><li><a href="#advanced-validation-strategies-leveling-up-your-form-game">Advanced Validation Strategies: Leveling Up Your Form Game</a><ul><li><a href="#real-time-validation-with-ajax">Real-time Validation with AJAX</a></li><li><a href="#handling-file-uploads-like-a-pro">Handling File Uploads Like a Pro</a></li></ul></li><li><a href="#sanitization-cleaning-up-the-riffraff">Sanitization: Cleaning Up the Riffraff</a><ul><li><a href="#word-press-sanitization-functions-your-new-best-friends">WordPress Sanitization Functions: Your New Best Friends</a></li><li><a href="#creating-custom-sanitization-methods">Creating Custom Sanitization Methods</a></li></ul></li><li><a href="#putting-it-all-together-a-complete-form-processing-example">Putting It All Together: A Complete Form Processing Example</a></li><li><a href="#wrapping-up-youre-now-a-form-security-ninja">Wrapping Up: You&#8217;re Now a Form Security Ninja!</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="the-shocking-truth-about-word-press-secure-form-security">The Shocking Truth About WordPress Secure Form Security</h2>



<p>Let&#8217;s kick things off with a jaw-dropping statistic: Did you know that a whopping <a href="https://www.accenture.com/us-en/insights/cyber-security-index" target="_blank" rel="noreferrer noopener">43% of cyberattacks target small businesses</a>, with many of these attacks exploiting vulnerabilities in web forms?</p>



<p>As a WordPress developer, you&#8217;re not just building websites – you have to create a digital fortress as well. And one of the <strong>most crucial battlegrounds</strong> in this cybersecurity war is the <strong>humble web form</strong>. Those innocent-looking input fields can be a hacker&#8217;s playground if left unchecked.</p>



<p>By the end of this guide, you&#8217;ll be armed with the knowledge and skills to turn your WordPress forms into impenetrable barriers against malicious inputs.</p>



<h2 class="wp-block-heading" id="why-should-you-care-about-input-validation-and-sanitization">Why Should You Care About Input Validation and Sanitization?</h2>



<p>Before we dive into the nitty-gritty, let&#8217;s take a moment to understand why we&#8217;re even bothering with all this validation and sanitization stuff.</p>



<h3 class="wp-block-heading" id="the-dynamic-duo-of-form-security">The Dynamic Duo of Form Security</h3>



<ul class="wp-block-list">
<li><strong>Input Validation</strong>: Think of this as your bouncer at the club door. It checks if the data entering your form meets your criteria. Is that email address actually an email address? Is that phone number made up of digits only? Validation says, &#8220;Hey you! Yeah, you with the weird input. You&#8217;re not getting in here!&#8221; This is primarily handled with JavaScript.<br></li>



<li><strong>Input Sanitization</strong>: This is like your form&#8217;s personal hygienist. Once data passes validation, sanitization cleans it up. It removes or encodes potentially harmful characters, ensuring that even if something sneaky slips through validation, it can&#8217;t wreak havoc on your system. This is primarily handled with PHP.</li>
</ul>



<h3 class="wp-block-heading" id="the-risks-of-skipping-security">The Risks of Skipping Security</h3>



<figure class="wp-block-image size-full"><img decoding="async" width="800" height="550" src="https://blog.gravyware.com/wp-content/uploads/2024/08/bad-character.jpg" alt="wordpress secure form hacker covering his face" class="wp-image-3461" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/bad-character.jpg 800w, https://blog.gravyware.com/wp-content/uploads/2024/08/bad-character-300x206.jpg 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/bad-character-768x528.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<p>Ignoring form security is like leaving your front door wide open in a neighborhood full of mischievous cats. While most visitors might be harmless, eventually one curious feline to knock over your prized vase. In the digital world, these &#8220;cats&#8221; come in the form of:</p>



<ul class="wp-block-list">
<li>SQL Injection attacks</li>



<li>Cross-Site Scripting (XSS)</li>



<li>Remote Code Execution</li>



<li>Data corruption</li>
</ul>



<p>Trust me, dealing with any of these is way less fun than cleaning up after a cat party. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f431.png" alt="🐱" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading" id="setting-up-your-word-press-form-handling-fortress">Setting Up Your WordPress Form-Handling Fortress</h2>



<p>First, we need to set up our WordPress development environment.</p>



<h3 class="wp-block-heading" id="the-tools-of-the-trade">The Tools of the Trade</h3>



<ol class="wp-block-list">
<li><strong>WordPress</strong>: Make sure you&#8217;re running the latest version.</li>



<li><strong>A code editor</strong>: I&#8217;m partial to <a href="https://www.jetbrains.com/phpstorm/" target="_blank" rel="noreferrer noopener nofollow">PHPStorm</a> or <a href="https://code.visualstudio.com" target="_blank" rel="noreferrer noopener nofollow">VSCode</a>, but use whatever makes your coding heart sing.</li>



<li><strong>A local development environment</strong>: Tools like Local by Flywheel or XAMPP are great for this.</li>



<li><strong>WordPress Debug Mode</strong>: Turn this on in your <strong>wp-config.php</strong> file. It&#8217;s like having a super-smart sidekick pointing out your mistakes. <a href="https://rankmath.com/blog/enable-debugging-in-wordpress/" target="_blank" rel="noreferrer noopener nofollow">Here&#8217;s one way</a>.</li>
</ol>



<h3 class="wp-block-heading" id="creating-your-custom-form-handling-plugin">Creating Your Custom Form-Handling Plugin</h3>



<p>Why a plugin? Because it keeps your functionality separate from your theme, making it portable and easier to maintain. Plus, it makes you feel like a real WordPress wizard. </p>



<p>Here&#8217;s a basic structure to get you started:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>&lt;?php
/**
 * Plugin Name: SuperSecure Form Handler
 * Description: Handles form inputs like a boss!
 * Version: 1.0
 * Author: Your Awesome Name
 */

if (!defined('ABSPATH')) exit; // Exit if accessed directly

class SuperSecureFormHandler {
    public function __construct() {
        add_action('init', array($this, 'init'));
    }

    public function init() {
        // We'll add our form handling magic here
    }
}

new SuperSecureFormHandler();</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">&lt;?php</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">/**</span></span>
<span class="line"><span style="color: #6E6A86; font-style: italic"> * Plugin Name: SuperSecure Form Handler</span></span>
<span class="line"><span style="color: #6E6A86; font-style: italic"> * Description: Handles form inputs like a boss!</span></span>
<span class="line"><span style="color: #6E6A86; font-style: italic"> * Version: 1.0</span></span>
<span class="line"><span style="color: #6E6A86; font-style: italic"> * Author: Your Awesome Name</span></span>
<span class="line"><span style="color: #6E6A86; font-style: italic"> </span><span style="color: #908CAA; font-style: italic">*/</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">defined</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;ABSPATH&#39;</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">exit</span><span style="color: #908CAA">;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Exit if accessed directly</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">class</span><span style="color: #E0DEF4"> </span><span style="color: #9CCFD8">SuperSecureFormHandler</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">public</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">__construct</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EA9A97">add_action</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;init&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">this</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;init&#39;</span><span style="color: #908CAA">));</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">public</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">init</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #908CAA">        </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> We&#39;ll add our form handling magic here</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">new</span><span style="color: #E0DEF4"> </span><span style="color: #9CCFD8">SuperSecureFormHandler</span><span style="color: #908CAA">();</span></span></code></pre></div>



<h2 class="wp-block-heading" id="basic-php-validation-techniques-your-first-line-of-defense">Basic PHP Validation Techniques: Your First Line of Defense</h2>



<p>Now that we&#8217;ve got our plugin set up, let&#8217;s start with some basic validation techniques. Think of these as the foundation of your fortress – not flashy, but absolutely essential.</p>



<h3 class="wp-block-heading" id="the-power-of-ph-ps-built-in-functions">The Power of PHP&#8217;s Built-in Functions</h3>



<p>PHP comes with a treasure trove of basic validation functions. Here are some of my favorites:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>// Is it an email?
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $errors[] = "Invalid email format";
}

// Is it a number?
if (!is_numeric($age)) {
    $errors[] = "Age must be a number";
}

// Is it within a range?
if ($age &lt; 18 || $age > 99) {
    $errors[] = "Age must be between 18 and 99";
}

// Is it not empty?
if (empty($name)) {
    $errors[] = "Name is required";
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Is it an email?</span></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">filter_var</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">email</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">FILTER_VALIDATE_EMAIL</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Invalid email format&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Is it a number?</span></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">is_numeric</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Age must be a number&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Is it within a range?</span></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&lt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">18</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">||</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">99</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Age must be between 18 and 99&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Is it not empty?</span></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">empty</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">name</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Name is required&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<h3 class="wp-block-heading" id="crafting-custom-validation-rules">Crafting Custom Validation Rules</h3>



<p>Sometimes, the built-in functions just won&#8217;t cut it. That&#8217;s when you need to roll up your sleeves and create custom validation rules. Here&#8217;s an example of validating a username:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function validate_username($username) {
    // Only allow alphanumeric characters and underscores
    if (!preg_match('/^&#91;a-zA-Z0-9_&#93;+$/', $username)) {
        return false;
    }
    
    // Username should be between 4 and 20 characters
    if (strlen($username) &lt; 4 || strlen($username) > 20) {
        return false;
    }
    
    return true;
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">validate_username</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Only allow alphanumeric characters and underscores</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">preg_match</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;/</span><span style="color: #3E8FB0">^</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">a-zA-Z0-9_</span><span style="color: #908CAA">&#93;</span><span style="color: #3E8FB0">+$</span><span style="color: #F6C177">/&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">false</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Username should be between 4 and 20 characters</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">strlen</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&lt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">4</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">||</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">strlen</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">20</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">false</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">true</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<h2 class="wp-block-heading" id="advanced-validation-strategies-leveling-up-your-form-game">Advanced Validation Strategies: Leveling Up Your Form Game</h2>



<p>Let&#8217;s explore some advanced techniques that&#8217;ll make your forms smoother than a fresh jar of Skippy.</p>



<h3 class="wp-block-heading" id="real-time-validation-with-ajax">Real-time Validation with AJAX</h3>



<p>Nobody likes waiting until they hit the submit button to find out they&#8217;ve messed up. With AJAX, you can provide real-time feedback as users fill out your form. Here&#8217;s a quick example using jQuery, which comes included with WordPress:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">JavaScript</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>$('#username').on('blur', function() {
    var username = $(this).val();
    $.ajax({
        url: ajaxurl, // This is defined by WordPress
        type: 'POST',
        data: {
            action: 'validate_username',
            username: username
        },
        success: function(response) {
            if (response.valid) {
                $('#username-error').hide();
            } else {
                $('#username-error').show().text(response.message);
            }
        }
    });
});</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #EA9A97">$</span><span style="color: #E0DEF4">(</span><span style="color: #F6C177">&#39;#username&#39;</span><span style="color: #E0DEF4">)</span><span style="color: #3E8FB0">.</span><span style="color: #EA9A97">on</span><span style="color: #E0DEF4">(</span><span style="color: #F6C177">&#39;blur&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">function</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">var</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">$</span><span style="color: #E0DEF4">(</span><span style="color: #E0DEF4; font-style: italic">this</span><span style="color: #E0DEF4">)</span><span style="color: #3E8FB0">.</span><span style="color: #EA9A97">val</span><span style="color: #E0DEF4">()</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #E0DEF4; font-style: italic">$</span><span style="color: #3E8FB0">.</span><span style="color: #EA9A97">ajax</span><span style="color: #E0DEF4">(</span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        url</span><span style="color: #908CAA">:</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">ajaxurl</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> This is defined by WordPress</span></span>
<span class="line"><span style="color: #E0DEF4">        type</span><span style="color: #908CAA">:</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;POST&#39;</span><span style="color: #908CAA">,</span></span>
<span class="line"><span style="color: #E0DEF4">        data</span><span style="color: #908CAA">:</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">            action</span><span style="color: #908CAA">:</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;validate_username&#39;</span><span style="color: #908CAA">,</span></span>
<span class="line"><span style="color: #E0DEF4">            username</span><span style="color: #908CAA">:</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">username</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA">},</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EA9A97">success</span><span style="color: #908CAA">:</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">function</span><span style="color: #908CAA">(</span><span style="color: #C4A7E7; font-style: italic">response</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">            </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> (</span><span style="color: #E0DEF4; font-style: italic">response</span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4; font-style: italic">valid</span><span style="color: #E0DEF4">) </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">                </span><span style="color: #EA9A97">$</span><span style="color: #E0DEF4">(</span><span style="color: #F6C177">&#39;#username-error&#39;</span><span style="color: #E0DEF4">)</span><span style="color: #3E8FB0">.</span><span style="color: #EA9A97">hide</span><span style="color: #E0DEF4">()</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">            </span><span style="color: #908CAA">}</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">else</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">                </span><span style="color: #EA9A97">$</span><span style="color: #E0DEF4">(</span><span style="color: #F6C177">&#39;#username-error&#39;</span><span style="color: #E0DEF4">)</span><span style="color: #3E8FB0">.</span><span style="color: #EA9A97">show</span><span style="color: #E0DEF4">()</span><span style="color: #3E8FB0">.</span><span style="color: #EA9A97">text</span><span style="color: #E0DEF4">(</span><span style="color: #E0DEF4; font-style: italic">response</span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4; font-style: italic">message</span><span style="color: #E0DEF4">)</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">            </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span><span style="color: #E0DEF4">)</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span><span style="color: #E0DEF4">)</span><span style="color: #908CAA">;</span></span></code></pre></div>



<p>And in your PHP file <strong>functions.php</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>add_action('wp_ajax_validate_username', 'ajax_validate_username');
add_action('wp_ajax_nopriv_validate_username', 'ajax_validate_username');

function ajax_validate_username() {
    $username = $_POST&#91;'username'&#93;;
    $is_valid = validate_username($username);
    
    wp_send_json(array(
        'valid' => $is_valid,
        'message' => $is_valid ? '' : 'Invalid username'
    ));
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #EA9A97">add_action</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;wp_ajax_validate_username&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;ajax_validate_username&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #EA9A97">add_action</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;wp_ajax_nopriv_validate_username&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;ajax_validate_username&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">ajax_validate_username</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;username&#39;</span><span style="color: #908CAA">&#93;;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">is_valid</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">validate_username</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EA9A97">wp_send_json</span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #F6C177">&#39;valid&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">is_valid</span><span style="color: #908CAA">,</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #F6C177">&#39;message&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">is_valid</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">?</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">:</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;Invalid username&#39;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">));</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<h3 class="wp-block-heading" id="handling-file-uploads-like-a-pro">Handling File Uploads Like a Pro</h3>



<p>File uploads can be a security nightmare if not handled correctly. Here&#8217;s how to validate file uploads without breaking a sweat (this code would be in your <strong>functions.php</strong> file):</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function validate_file_upload($file) {
    $allowed_types = array('jpg', 'jpeg', 'png', 'gif');
    $max_size = 5 * 1024 * 1024; // 5MB
    
    $file_name = $file&#91;'name'&#93;;
    $file_size = $file&#91;'size'&#93;;
    $file_tmp = $file&#91;'tmp_name'&#93;;
    
    // Check file extension
    $ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
    if (!in_array($ext, $allowed_types)) {
        return "Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.";
    }
    
    // Check file size
    if ($file_size > $max_size) {
        return "Sorry, your file is too large. Max size is 5MB.";
    }
    
    // Check MIME type
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime = finfo_file($finfo, $file_tmp);
    finfo_close($finfo);
    
    if (!in_array($mime, array('image/jpeg', 'image/png', 'image/gif'))) {
        return "File type not allowed.";
    }
    
    return true; // File is valid
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">validate_file_upload</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">allowed_types</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;jpg&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;jpeg&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;png&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;gif&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">max_size</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">5</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">*</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">1024</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">*</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">1024</span><span style="color: #908CAA">;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> 5MB</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file_name</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;name&#39;</span><span style="color: #908CAA">&#93;;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file_size</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;size&#39;</span><span style="color: #908CAA">&#93;;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file_tmp</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;tmp_name&#39;</span><span style="color: #908CAA">&#93;;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Check file extension</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">ext</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">strtolower</span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">pathinfo</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file_name</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">PATHINFO_EXTENSION</span><span style="color: #908CAA">));</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">ext</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">allowed_types</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Check file size</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file_size</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">max_size</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Sorry, your file is too large. Max size is 5MB.&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Check MIME type</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">finfo</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">finfo_open</span><span style="color: #908CAA">(</span><span style="color: #F6C177">FILEINFO_MIME_TYPE</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">mime</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">finfo_file</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">finfo</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">file_tmp</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">finfo_close</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">finfo</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">mime</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;image/jpeg&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;image/png&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;image/gif&#39;</span><span style="color: #908CAA">)))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;File type not allowed.&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">true</span><span style="color: #908CAA">;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> File is valid</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<h2 class="wp-block-heading" id="sanitization-cleaning-up-the-riffraff">Sanitization: Cleaning Up the Riffraff</h2>



<p>Validation is great, but sometimes sneaky data can still slip through. That&#8217;s where sanitization comes in, ensuring that even if bad data gets past validation, it can&#8217;t cause any mischief.</p>



<h3 class="wp-block-heading" id="word-press-sanitization-functions-your-new-best-friends">WordPress Sanitization Functions: Your New Best Friends</h3>



<p>WordPress comes with a bunch of handy sanitization functions. Here are some you&#8217;ll want to keep in your back pocket:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>// For plain text
$clean_text = sanitize_text_field($_POST&#91;'user_input'&#93;);

// For HTML content (like from a WYSIWYG editor)
$clean_html = wp_kses_post($_POST&#91;'html_input'&#93;);

// For emails
$clean_email = sanitize_email($_POST&#91;'email_input'&#93;);

// For URLs
$clean_url = esc_url_raw($_POST&#91;'url_input'&#93;);</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> For plain text</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_text</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">sanitize_text_field</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;user_input&#39;</span><span style="color: #908CAA">&#93;);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> For HTML content (like from a WYSIWYG editor)</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_html</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">wp_kses_post</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;html_input&#39;</span><span style="color: #908CAA">&#93;);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> For emails</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_email</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">sanitize_email</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;email_input&#39;</span><span style="color: #908CAA">&#93;);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> For URLs</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_url</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">esc_url_raw</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;url_input&#39;</span><span style="color: #908CAA">&#93;);</span></span></code></pre></div>



<h3 class="wp-block-heading" id="creating-custom-sanitization-methods">Creating Custom Sanitization Methods</h3>



<p>Sometimes, you need a bit more control. Here&#8217;s an example of a custom sanitization method for a username:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>function sanitize_username($username) {
    // Remove any HTML tags
    $clean = strip_tags($username);
    
    // Remove any non-alphanumeric characters except underscores
    $clean = preg_replace('/&#91;^a-zA-Z0-9_&#93;/', '', $clean);
    
    // Trim whitespace and limit to 20 characters
    return substr(trim($clean), 0, 20);
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">sanitize_username</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Remove any HTML tags</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">strip_tags</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Remove any non-alphanumeric characters except underscores</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">preg_replace</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;/</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">^a-zA-Z0-9_</span><span style="color: #908CAA">&#93;</span><span style="color: #F6C177">/&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Trim whitespace and limit to 20 characters</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">substr</span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">trim</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean</span><span style="color: #908CAA">),</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">0</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">20</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<h2 class="wp-block-heading" id="putting-it-all-together-a-complete-form-processing-example">Putting It All Together: A Complete Form Processing Example</h2>



<p>Let&#8217;s bring everything we&#8217;ve learned together into a complete form processing example (<strong>in functions.php</strong>):</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>add_action('admin_post_nopriv_submit_user_form', 'handle_user_form');
add_action('admin_post_submit_user_form', 'handle_user_form');

function handle_user_form() {
    // Verify nonce for security
    if (!isset($_POST&#91;'user_form_nonce'&#93;) || !wp_verify_nonce($_POST&#91;'user_form_nonce'&#93;, 'submit_user_form')) {
        wp_die('Security check failed');
    }
    
    $username = isset($_POST&#91;'username'&#93;) ? $_POST&#91;'username'&#93; : '';
    $email = isset($_POST&#91;'email'&#93;) ? $_POST&#91;'email'&#93; : '';
    $age = isset($_POST&#91;'age'&#93;) ? $_POST&#91;'age'&#93; : '';
    
    $errors = array();
    
    // Validate inputs
    if (!validate_username($username)) {
        $errors[] = "Invalid username";
    }
    
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $errors[] = "Invalid email format";
    }
    
    if (!is_numeric($age) || $age &lt; 18 || $age > 99) {
        $errors[] = "Age must be a number between 18 and 99";
    }
    
    // If there are errors, redirect back to the form
    if (!empty($errors)) {
        $error_string = implode('&amp;', array_map('urlencode', $errors));
        wp_redirect(add_query_arg('errors', $error_string, wp_get_referer()));
        exit;
    }
    
    // Sanitize inputs
    $clean_username = sanitize_username($username);
    $clean_email = sanitize_email($email);
    $clean_age = absint($age);
    
    // Process the form (e.g., save to database)
    // ...
    
    // Redirect to success page
    wp_redirect(add_query_arg('success', '1', wp_get_referer()));
    exit;
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #EA9A97">add_action</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;admin_post_nopriv_submit_user_form&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;handle_user_form&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #EA9A97">add_action</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;admin_post_submit_user_form&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;handle_user_form&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">handle_user_form</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Verify nonce for security</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">isset</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;user_form_nonce&#39;</span><span style="color: #908CAA">&#93;)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">||</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">!</span><span style="color: #EA9A97">wp_verify_nonce</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;user_form_nonce&#39;</span><span style="color: #908CAA">&#93;,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;submit_user_form&#39;</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EA9A97">wp_die</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;Security check failed&#39;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">isset</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;username&#39;</span><span style="color: #908CAA">&#93;)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">?</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;username&#39;</span><span style="color: #908CAA">&#93;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">:</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">email</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">isset</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;email&#39;</span><span style="color: #908CAA">&#93;)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">?</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;email&#39;</span><span style="color: #908CAA">&#93;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">:</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">isset</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;age&#39;</span><span style="color: #908CAA">&#93;)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">?</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">_POST</span><span style="color: #908CAA">&#91;</span><span style="color: #F6C177">&#39;age&#39;</span><span style="color: #908CAA">&#93;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">:</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">();</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Validate inputs</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EA9A97">validate_username</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Invalid username&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">filter_var</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">email</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">FILTER_VALIDATE_EMAIL</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Invalid email format&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">is_numeric</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">||</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&lt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">18</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">||</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">99</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">[]</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Age must be a number between 18 and 99&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> If there are errors, redirect back to the form</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">empty</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">error_string</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">implode</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;&amp;&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array_map</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;urlencode&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">errors</span><span style="color: #908CAA">));</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EA9A97">wp_redirect</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">add_query_arg</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;errors&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">error_string</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">wp_get_referer</span><span style="color: #908CAA">()));</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">exit</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Sanitize inputs</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_username</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">sanitize_username</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">username</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_email</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">sanitize_email</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">email</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">clean_age</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">absint</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">age</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Process the form (e.g., save to database)</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> ...</span></span>
<span class="line"><span style="color: #E0DEF4">    </span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Redirect to success page</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EA9A97">wp_redirect</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">add_query_arg</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;success&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;1&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">wp_get_referer</span><span style="color: #908CAA">()));</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">exit</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<h2 class="wp-block-heading" id="wrapping-up-youre-now-a-form-security-ninja">Wrapping Up: You&#8217;re Now a Form Security Ninja!</h2>



<p>Congratulations! You&#8217;ve just leveled up your WordPress form-handling skills. By implementing these validation and sanitization techniques, you&#8217;re following best practices and protecting your users and your reputation.</p>



<p>The world of web security is always evolving, so stay curious and keep learning.</p>



<p>Happy coding, and if you have any questions, just ask!</p>



<p></p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Use PHP in_array() Function</title>
		<link>https://blog.gravyware.com/php-in_array</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Thu, 15 Aug 2024 22:52:52 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=3434</guid>

					<description><![CDATA[The PHP in_array() function allows you to check if a specific value exists in an array. It has a few nuances that can drive you crazy until you figure them out.]]></description>
										<content:encoded><![CDATA[
<p>The PHP <strong>in_array()</strong> function is a powerful tool in PHP that allows you to check if a specific value exists in an array. This function is handy when you need to validate input, filter data, or implement search functionality in your PHP applications.</p>



<p>It&#8217;s a simple function, but it has a few nuances that can drive you crazy until you figure them out. Let&#8217;s go over everything.</p>



<h2 class="wp-block-heading">Syntax and Parameters</h2>



<p>The basic syntax of the <strong>in_array()</strong> function is as follows:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="bool in_array ( mixed $needle , array $haystack [, bool $strict = false ] )" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">bool</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">mixed</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">needle</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">array</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">haystack</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">[,</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">bool</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">strict</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">false</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">]</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">)</span></span></code></pre></div>



<p>Let&#8217;s break down the parameters:</p>



<ol class="wp-block-list">
<li>$needle: The value to search for in the array.</li>



<li>$haystack: The array to search in.</li>



<li>$strict (optional): If set to <strong>true</strong>, the function will also check for type equality.</li>
</ol>



<p>The function returns <strong>true</strong> if the <strong>$needle</strong> is found in the <strong>$haystack</strong>, and <strong>false</strong> otherwise.</p>



<h2 class="wp-block-heading">Basic Usage</h2>



<p>Here&#8217;s a simple example of how to use <strong>in_array()</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="$fruits = array(&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;);
if (in_array(&quot;banana&quot;, $fruits)) {
    echo &quot;Found banana!&quot;;
} else {
    echo &quot;Banana not found.&quot;;
}" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">fruits</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;apple&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;banana&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;orange&quot;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;banana&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">fruits</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Found banana!&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">else</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Banana not found.&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<p>In this example, the output will be &#8220;Found banana!&#8221; because &#8220;banana&#8221; exists in the <strong>$fruits</strong> array.</p>



<h2 class="wp-block-heading">Strict Mode</h2>



<p>The third parameter, <strong>$strict</strong>, is particularly important when dealing with different data types. When set to <strong>true</strong>, it performs a strict comparison (===) instead of a loose comparison (==).</p>



<p>Consider this example:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="$numbers = array(1, &quot;2&quot;, 3);

var_dump(in_array(2, $numbers));        // Output: bool(true)
var_dump(in_array(2, $numbers, true));  // Output: bool(false)" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">numbers</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;2&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">3</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #EB6F92; font-style: italic">var_dump</span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">2</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">numbers</span><span style="color: #908CAA">));</span><span style="color: #E0DEF4">        </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Output: bool(true)</span></span>
<span class="line"><span style="color: #EB6F92; font-style: italic">var_dump</span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">2</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">numbers</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">true</span><span style="color: #908CAA">));</span><span style="color: #E0DEF4">  </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Output: bool(false)</span></span></code></pre></div>



<p>In the first case, <strong>in_array()</strong> returns <strong>true</strong> because it finds the string &#8220;2&#8221;, which is loosely equal to the integer 2. In the second case, with strict mode enabled, it returns <strong>false</strong> because there is no integer 2 in the array.</p>



<h2 class="wp-block-heading">This Gave Me Trouble</h2>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="800" height="533" src="https://blog.gravyware.com/wp-content/uploads/2024/08/stressed_developer_800x533.jpg" alt="A Software Developer who can't figure out why the PHP In_array function isn't working for him" class="wp-image-3441" style="width:899px;height:auto" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/stressed_developer_800x533.jpg 800w, https://blog.gravyware.com/wp-content/uploads/2024/08/stressed_developer_800x533-300x200.jpg 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/stressed_developer_800x533-768x512.jpg 768w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<p>I couldn&#8217;t figure out why some searches worked, while others did not.</p>



<p>This works:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="// single level array
$array = array(5) {
	[&quot;keywords&quot;]=&gt; string(5) &quot;74.51&quot;
	[&quot;wordCount&quot;]=&gt; string(1) &quot;0&quot;
	[&quot;linkCount&quot;]=&gt; string(1) &quot;0&quot;
	[&quot;headingCount&quot;]=&gt; string(1) &quot;0&quot;
	[&quot;mediaCount&quot;]=&gt; string(1) &quot;0&quot; }
 }
$test_result = in_array(74.51, $array) // test_result is true
" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> single level array</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">array</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">5</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;keywords&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">5</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;74.51&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;wordCount&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;linkCount&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;headingCount&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;mediaCount&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4"> }</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">test_result</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">74</span><span style="color: #908CAA">.</span><span style="color: #EA9A97">51</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">array</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> test_result is true</span></span>
<span class="line"></span></code></pre></div>



<p>This does not until you reference the sub-array (in <strong>$test_result2</strong>):</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="// an array exists within another array
$array = array(6) {
	[&quot;width&quot;]=&gt; int(30)
	[&quot;height&quot;]=&gt; int(30)
	[&quot;file&quot;]=&gt; string(31) &quot;2022/08/icon_mountainbiking.png&quot;
	[&quot;filesize&quot;]=&gt; int(1670)
	[&quot;sizes&quot;]=&gt; array(0) { }
	[&quot;image_meta&quot;]=&gt; array(12) {
		[&quot;aperture&quot;]=&gt; string(1) &quot;0&quot;
		[&quot;credit&quot;]=&gt; string(0) &quot;&quot;
		[&quot;camera&quot;]=&gt; string(0) &quot;&quot;
		[&quot;caption&quot;]=&gt; string(0) &quot;&quot;
		[&quot;created_timestamp&quot;]=&gt; string(1) &quot;0&quot;
		[&quot;copyright&quot;]=&gt; string(0) &quot;&quot;
		[&quot;focal_length&quot;]=&gt; string(1) &quot;0&quot;
		[&quot;iso&quot;]=&gt; string(1) &quot;0&quot;
		[&quot;shutter_speed&quot;]=&gt; string(1) &quot;0&quot;
		[&quot;title&quot;]=&gt; string(0) &quot;&quot;
		[&quot;orientation&quot;]=&gt; string(1) &quot;0&quot;
		[&quot;keywords&quot;]=&gt; array(0) { }
	}
}
$test_result = in_array(0, $array) //test_result is &quot;false&quot;
$test_result2 = in_array(0, $array['image_meta']) //test_result is &quot;true&quot;" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> an array exists within another array</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">array</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">6</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;width&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">int</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">30</span><span style="color: #908CAA">)</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;height&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">int</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">30</span><span style="color: #908CAA">)</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;file&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">31</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;2022/08/icon_mountainbiking.png&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;filesize&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">int</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1670</span><span style="color: #908CAA">)</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;sizes&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;image_meta&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">12</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;aperture&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;credit&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;camera&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;caption&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;created_timestamp&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;copyright&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;focal_length&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;iso&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;shutter_speed&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;title&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;orientation&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">string</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">1</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;0&quot;</span></span>
<span class="line"><span style="color: #E0DEF4">		</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;keywords&quot;</span><span style="color: #908CAA">]</span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">	</span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">test_result</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">array</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic">test_result is &quot;false&quot;</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">test_result2</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">in_array</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">0</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">array</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&#39;image_meta&#39;</span><span style="color: #908CAA">])</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic">test_result is &quot;true&quot;</span></span></code></pre></div>



<p class="has-large-font-size">Findings:</p>



<p>You must reference the element that contains the array you want to search. You cannot reference the top-level array only and expect it to traverse down through sub-arrays.</p>



<figure class="wp-block-pullquote is-style-default has-theme-palette-7-background-color has-background has-medium-font-size"><blockquote><p>The in_array() function alone does not recurse through multidimensional arrays.<br><br>The command searches a single-level only.</p></blockquote></figure>



<h2 class="wp-block-heading">Searching in Multidimensional Arrays</h2>



<p>While <strong>in_array()</strong> works great for one-dimensional arrays, it doesn&#8217;t directly search nested arrays. To search in multidimensional arrays, you&#8217;ll need to use it in combination with other functions or write a custom function.</p>



<p>Here&#8217;s an example of how you might search a multidimensional array:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="function in_array_r($needle, $haystack, $strict = false) {
    foreach ($haystack as $item) {
        if (($strict ? $item === $needle : $item == $needle) || (is_array($item) &amp;&amp; in_array_r($needle, $item, $strict))) {
            return true;
        }
    }
    return false;
}

$users = array(
    array(&quot;name&quot; =&gt; &quot;John&quot;, &quot;age&quot; =&gt; 25),
    array(&quot;name&quot; =&gt; &quot;Jane&quot;, &quot;age&quot; =&gt; 30)
);

var_dump(in_array_r(&quot;Jane&quot;, $users));  // Output: bool(true)" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">in_array_r</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">needle</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">haystack</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">strict</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">false</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">foreach</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">haystack</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">as</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">item</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">((</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">strict</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">?</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">item</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">===</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">needle</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">:</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">item</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">==</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">needle</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">||</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">is_array</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">item</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">&amp;&amp;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">in_array_r</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">needle</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">item</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">strict</span><span style="color: #908CAA">)))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">            </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">true</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">false</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">users</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;name&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;John&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;age&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">25</span><span style="color: #908CAA">),</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;name&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Jane&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;age&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">30</span><span style="color: #908CAA">)</span></span>
<span class="line"><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #EB6F92; font-style: italic">var_dump</span><span style="color: #908CAA">(</span><span style="color: #EA9A97">in_array_r</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;Jane&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">users</span><span style="color: #908CAA">));</span><span style="color: #E0DEF4">  </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Output: bool(true)</span></span></code></pre></div>



<h2 class="wp-block-heading">Performance Considerations</h2>



<p>While <strong>in_array()</strong> is convenient, it can be slower for large arrays because it performs a linear search. For better performance with large datasets, consider using <strong>array_flip()</strong> in combination with <strong>isset()</strong>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="$fruits = array(&quot;apple&quot;, &quot;banana&quot;, &quot;orange&quot;);
$flipped = array_flip($fruits);

if (isset($flipped[&quot;banana&quot;])) {
    echo &quot;Found banana!&quot;;
}" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">fruits</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&quot;apple&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;banana&quot;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;orange&quot;</span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">flipped</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array_flip</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">fruits</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #EB6F92; font-style: italic">isset</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">flipped</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&quot;banana&quot;</span><span style="color: #908CAA">]))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&quot;Found banana!&quot;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span></code></pre></div>



<p>This method is generally faster for large arrays because <strong>isset()</strong> has constant time complexity.</p>



<h2 class="wp-block-heading">Common Use Cases</h2>



<ol class="wp-block-list">
<li><strong>Input Validation</strong>: Check if a user&#8217;s input is in a list of allowed values.</li>



<li><strong>Filtering Data</strong>: Remove or keep elements based on whether they exist in another array.</li>



<li><strong>Menu Highlighting</strong>: Determine if the current page is in the list of menu items.</li>



<li><strong>Permission Checking</strong>: Verify if a user has a specific permission from a list.</li>
</ol>



<h2 class="wp-block-heading">Conclusion</h2>



<p>The <strong>in_array()</strong> function is a versatile tool in PHP for checking the existence of values in arrays. Unfortunately, I&#8217;ve spent many hours trying to debug an in_array() command and wondering why it wasn&#8217;t finding a value that was in a sub-array. Seems simple, but it&#8217;s easy to forget.</p>



<p>Remember to consider performance implications for large datasets and explore alternative methods when dealing with multidimensional arrays.</p>



<p>As with any PHP function, it&#8217;s always a good idea to refer to the <a href="https://www.php.net/docs.php" target="_blank" rel="noreferrer noopener">official PHP documentation</a> for the most up-to-date information and additional details about <strong>in_array()</strong> and related functions.</p>



<p>Happy coding!</p>



<p>P.S. Read this if you want to <a href="https://blog.gravyware.com/what-is-ec2-setup-a-web-server-tutorial-in-aws">set up your own PHP server in AWS</a>.</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Use Shortcodes in WordPress: A Beginner&#8217;s Guide</title>
		<link>https://blog.gravyware.com/how-to-use-shortcodes-in-wordpress</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Wed, 07 Aug 2024 20:56:43 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=3390</guid>

					<description><![CDATA[Learn how to effectively use a shortcode in WordPress without writing complex code. This guide covers every method of using shortcodes in the editor and code.]]></description>
										<content:encoded><![CDATA[
<p>Shortcodes are convenient tools that allow you to add features or styled content to your posts or pages without needing to write complex code. They are enclosed in square brackets and may include attributes that customize their behavior.</p>



<p>We&#8217;ll explore how to find shortcodes from various sources such as WordPress core, themes, and plugins. Additionally, we&#8217;ll cover how to use shortcodes in both the block editor (Gutenberg) and the classic editor.</p>



<div class="wp-block-rank-math-toc-block has-theme-palette-7-background-color has-background" style="margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--20)" id="rank-math-toc"><h2>Table of Contents</h2><nav><ul><li><a href="#lets-get-started">Let&#8217;s get started</a></li><li><a href="#understanding-shortcodes">Understanding shortcodes</a></li><li><a href="#finding-shortcodes">Finding Shortcodes</a><ul><li><a href="#shortcodes-finder-plugin">Shortcodes Finder Plugin</a></li></ul></li><li><a href="#how-to-reference-a-shortcode">How to Reference a Shortcode</a><ul><li><a href="#in-the-block-editor-gutenberg">In the Block Editor (Gutenberg)</a></li><li><a href="#in-the-classic-editor">In the Classic Editor</a></li></ul></li><li><a href="#using-shortcodes-in-widgets">Using Shortcodes in Widgets</a></li><li><a href="#using-shortcodes-with-attributes">Using Shortcodes with Attributes</a></li><li><a href="#using-shortcodes-in-php-code">Using Shortcodes in PHP code</a></li><li><a href="#creating-shortcodes-in-php-code">Creating Shortcodes in PHP code</a></li><li><a href="#troubleshooting-shortcodes">Troubleshooting Shortcodes</a></li><li><a href="#best-practices">Best Practices</a></li></ul></nav></div>



<h2 class="wp-block-heading" id="lets-get-started">Let&#8217;s get started</h2>



<p>Shortcodes are convenient tools in WordPress that allow you to add features or styled content to your posts or pages without needing to write complex code. Here&#8217;s how to use shortcodes created by others:</p>



<h2 class="wp-block-heading" id="understanding-shortcodes">Understanding shortcodes</h2>



<p>Shortcodes typically look like this: [shortcode_name] or [shortcode_name attribute=&#8221;value&#8221;].</p>



<p>They&#8217;re enclosed in square brackets and may include attributes that customize their behavior.</p>



<h2 class="wp-block-heading" id="finding-shortcodes">Finding Shortcodes</h2>



<p>Shortcodes can come from various sources:</p>



<ul class="wp-block-list">
<li>WordPress core (e.g., gallery, caption)</li>



<li>Your theme</li>



<li>Plugins you&#8217;ve installed</li>
</ul>



<p>To find available shortcodes:</p>



<ul class="wp-block-list">
<li>Check your theme&#8217;s documentation</li>



<li>Look in the settings or documentation of your installed plugins</li>



<li>Use a plugin like &#8220;Shortcodes Finder&#8221; to discover shortcodes on your site</li>
</ul>



<p>To find the available shortcodes on your website, check your theme&#8217;s documentation, the settings or documentation of your installed plugins, or use a plugin like Shortcode Finder. To install it, go to plugins, click &#8220;Add New,&#8221; type &#8220;Shortcode Finder,&#8221; and search for it.</p>



<h3 class="wp-block-heading" id="shortcodes-finder-plugin">Shortcodes Finder Plugin</h3>



<p>First, install this free plugin.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="569" height="305" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-3.png" alt="shortcodes finder plugin" class="wp-image-3393" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-3.png 569w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-3-300x161.png 300w" sizes="auto, (max-width: 569px) 100vw, 569px" /></figure>



<p>To use the plugin, go to the &#8220;Tools&#8221; admin section, and find the link called &#8220;Shortcodes Finder&#8221;.</p>



<p>Click &#8220;Tools&#8221;, and then &#8220;Shortcodes Finder&#8221; near the bottom.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-13.png" alt="Step 4: Click on Tools then Shortcodes Finder near the bottom" class="wp-image-3423" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-13.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-13-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-13-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-13-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p></p>



<p>In the Shortcodes Finder tool, go to Documentation to find everything or locate unused shortcodes.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-12.png" alt="Step 5: Click on Documentation" class="wp-image-3422" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-12.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-12-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-12-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-12-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p></p>



<p>If you click on the WordPress front end and do a search, it will display the various shortcodes you can use.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-14.png" alt="Step 6: Click here" class="wp-image-3424" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-14.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-14-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-14-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-14-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p></p>



<p>You&#8217;ll see some built-in WordPress shortcodes listed.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-11.png" alt="Step 8: Youll see some built-in WordPress shortcodes listed" class="wp-image-3421" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-11.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-11-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-11-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-11-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p>You have audio, caption, gallery, and others. These are some of the shortcodes built into WordPress that you can use immediately.</p>



<h2 class="wp-block-heading" id="how-to-reference-a-shortcode">How to Reference a Shortcode</h2>



<p>How do we actually use shortcodes in a WordPress site? The methods depend on how your site is setup. Your theme will most likely have either a block editor or the classic editor when editing pages and posts.</p>



<h3 class="wp-block-heading" id="in-the-block-editor-gutenberg">In the Block Editor (Gutenberg)</h3>



<p>While in the area you want to place the shortcode, type &#8220;/&#8221; to bring up options.</p>



<p>Click on &#8220;[ / ] Shortcode&#8221;.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-15.png" alt="Step 13: Click on    Shortcode" class="wp-image-3425" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-15.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-15-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-15-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-15-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p>Enter your shortcode in the box and hit save.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-6.png" alt="Step 16: Click on  gallery ids   37383940  " class="wp-image-3416" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-6.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-6-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-6-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-6-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<h3 class="wp-block-heading" id="in-the-classic-editor">In the Classic Editor</h3>



<p>In the classic editor, you need to go to the Text section of a page (Top right corner of the text area) and manually type out the shortcode.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="726" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-7.png" alt="Step 20: Click on Text" class="wp-image-3417" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-7.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-7-300x142.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-7-1024x485.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-7-768x364.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p></p>



<p>Simply <strong>type or paste the shortcode directly into the content area</strong> where you want it to appear and Save the page or post.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="800" height="382" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-5.png" alt="" class="wp-image-3401" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-5.png 800w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-5-300x143.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-5-768x367.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></figure>



<p>When viewed from the front end, the shortcode will be deciphered by WordPress, and the result will be displayed to the user in their browser window.</p>



<p></p>



<h2 class="wp-block-heading" id="using-shortcodes-in-widgets">Using Shortcodes in Widgets</h2>



<p>You can also use shortcuts in widgets. To use shortcuts in widgets, go to Appearance, then Widgets.</p>



<p><strong>1.</strong> Go to Appearance > Widgets in your WordPress dashboard</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="822" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-16.png" alt="Step 1: Go to Appearance  Widgets in your WordPress dashboard" class="wp-image-3426" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-16.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-16-300x161.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-16-1024x549.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-16-768x412.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p><strong>2.</strong> You can see that this site already uses shortcodes in the &#8220;Sidebar 1&#8221; widget.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="822" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-8.png" alt="Step 2: You can see that this site already uses shortcodes in the Sidebar 1 widget" class="wp-image-3418" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-8.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-8-300x161.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-8-1024x549.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-8-768x412.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p>To add another one, click the Add button. Check the shortcode type, then type it in.</p>



<p><strong>3.</strong> Click on &#8220;+&#8221; to add a new shortcode reference.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="822" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-9.png" alt="Step 3: Click on " class="wp-image-3419" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-9.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-9-300x161.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-9-1024x549.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-9-768x412.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p><strong>4.</strong> Click on &#8220;Custom HTML&#8221;. You might have to search for it if it&#8217;s not one of the first few.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1532" height="822" src="https://blog.gravyware.com/wp-content/uploads/2024/08/image-10.png" alt="Step 4: Click on Custom HTML You might have to search for it if its not one of the first few" class="wp-image-3420" srcset="https://blog.gravyware.com/wp-content/uploads/2024/08/image-10.png 1532w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-10-300x161.png 300w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-10-1024x549.png 1024w, https://blog.gravyware.com/wp-content/uploads/2024/08/image-10-768x412.png 768w" sizes="auto, (max-width: 1532px) 100vw, 1532px" /></figure>



<p>Type or paste in the new shortcode and hit Save.</p>



<h2 class="wp-block-heading" id="using-shortcodes-with-attributes">Using Shortcodes with Attributes</h2>



<p>Many shortcodes accept attributes to customize their output. Check your theme or plugin documentation to see what&#8217;s available.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="[shortcode_name attribute1=&quot;value1&quot; attribute2=&quot;value2&quot;]" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #E0DEF4">[</span><span style="color: #E0DEF4; font-style: italic">shortcode_name</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">attribute1</span><span style="color: #3E8FB0">=</span><span style="color: #F6C177">&quot;value1&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">attribute2</span><span style="color: #3E8FB0">=</span><span style="color: #F6C177">&quot;value2&quot;</span><span style="color: #E0DEF4">]</span></span></code></pre></div>



<p></p>



<p>Here&#8217;s an example using a hypothetical &#8220;slider&#8221; shortcode:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="[slider id=&quot;homepage&quot; speed=&quot;500&quot; arrows=&quot;true&quot;]" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #E0DEF4">[</span><span style="color: #E0DEF4; font-style: italic">slider</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">id</span><span style="color: #3E8FB0">=</span><span style="color: #F6C177">&quot;homepage&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">speed</span><span style="color: #3E8FB0">=</span><span style="color: #F6C177">&quot;500&quot;</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">arrows</span><span style="color: #3E8FB0">=</span><span style="color: #F6C177">&quot;true&quot;</span><span style="color: #E0DEF4">]</span></span></code></pre></div>



<p></p>



<p>Here&#8217;s a gallery of specific images. The <strong>&#8220;gallery&#8221;</strong> shortcode without the IDs attribute will return all images associated with that particular page or post.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" data-code="" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #E0DEF4">[</span><span style="color: #E0DEF4; font-style: italic">gallery</span><span style="color: #E0DEF4"> </span><span style="color: #E0DEF4; font-style: italic">ids</span><span style="color: #3E8FB0">=</span><span style="color: #F6C177">&quot;123,124,125&quot;</span><span style="color: #E0DEF4">]</span></span></code></pre></div>



<p></p>



<h2 class="wp-block-heading" id="using-shortcodes-in-php-code">Using Shortcodes in PHP code</h2>



<p>Let&#8217;s say you&#8217;re creating a custom theme and need to insert a shortcode directly within the PHP code.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="&lt;?php echo do_shortcode('[your_shortcode]'); ?&gt;
//simply replace &quot;your_shortcode&quot; with your actual shortcode and you're set." style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">&lt;?php</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">do_shortcode</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;[your_shortcode]&#39;</span><span style="color: #908CAA">);</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">?&gt;</span></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic">simply replace &quot;your_shortcode&quot; with your actual shortcode and you&#39;re set.</span></span></code></pre></div>



<p></p>



<h2 class="wp-block-heading" id="creating-shortcodes-in-php-code">Creating Shortcodes in PHP code</h2>



<p>This bit is a bit more advanced, but here&#8217;s how you can create a completely new shortcode for your theme. The following code would go into your <strong>functions.php</strong> file.</p>



<p>The new shortcode &#8211; <strong>[last_10_posts]</strong> &#8211; will execute the code below and return the most recent 10 post titles.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#e0def4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2d2b46;color:#cecbee">PHP</span><span role="button" tabindex="0" data-code="function last_10_posts_shortcode() {
    // Query for the last 10 posts
    $args = array(
        'numberposts' =&gt; 10,
        'post_status' =&gt; 'publish',
    );
    $recent_posts = wp_get_recent_posts($args);

    // Start output buffering
    ob_start();

    // Check if there are any posts
    if (!empty($recent_posts)) {
        echo '&lt;ul&gt;';
        foreach ($recent_posts as $post) {
            echo '&lt;li&gt;&lt;a href=&quot;' . get_permalink($post['ID']) . '&quot;&gt;' . esc_html($post['post_title']) . '&lt;/a&gt;&lt;/li&gt;';
        }
        echo '&lt;/ul&gt;';
    } else {
        echo '&lt;p&gt;No recent posts found.&lt;/p&gt;';
    }

    // Get the output buffer content
    $output = ob_get_clean();

    return $output;
}

// Register the shortcode
add_shortcode('last_10_posts', 'last_10_posts_shortcode');" style="color:#e0def4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki rose-pine-moon" style="background-color: #232136" tabindex="0"><code><span class="line"><span style="color: #3E8FB0">function</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">last_10_posts_shortcode</span><span style="color: #908CAA">()</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Query for the last 10 posts</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">args</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">array</span><span style="color: #908CAA">(</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #F6C177">&#39;numberposts&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">10</span><span style="color: #908CAA">,</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #F6C177">&#39;post_status&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=&gt;</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;publish&#39;</span><span style="color: #908CAA">,</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">);</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">recent_posts</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">wp_get_recent_posts</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">args</span><span style="color: #908CAA">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Start output buffering</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #EB6F92; font-style: italic">ob_start</span><span style="color: #908CAA">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Check if there are any posts</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">if</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #3E8FB0">!</span><span style="color: #EB6F92; font-style: italic">empty</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">recent_posts</span><span style="color: #908CAA">))</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;ul&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #3E8FB0">foreach</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">recent_posts</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">as</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">post</span><span style="color: #908CAA">)</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">            </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;li&gt;&lt;a href=&quot;&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">get_permalink</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">post</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&#39;ID&#39;</span><span style="color: #908CAA">])</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&quot;&gt;&#39;</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #EA9A97">esc_html</span><span style="color: #908CAA">(</span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">post</span><span style="color: #908CAA">[</span><span style="color: #F6C177">&#39;post_title&#39;</span><span style="color: #908CAA">])</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">.</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;/a&gt;&lt;/li&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #908CAA">}</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;/ul&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">else</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA">{</span></span>
<span class="line"><span style="color: #E0DEF4">        </span><span style="color: #EB6F92; font-style: italic">echo</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;&lt;p&gt;No recent posts found.&lt;/p&gt;&#39;</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA">    </span><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Get the output buffer content</span></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">output</span><span style="color: #E0DEF4"> </span><span style="color: #3E8FB0">=</span><span style="color: #E0DEF4"> </span><span style="color: #EB6F92; font-style: italic">ob_get_clean</span><span style="color: #908CAA">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #E0DEF4">    </span><span style="color: #3E8FB0">return</span><span style="color: #E0DEF4"> </span><span style="color: #908CAA; font-style: italic">$</span><span style="color: #E0DEF4; font-style: italic">output</span><span style="color: #908CAA">;</span></span>
<span class="line"><span style="color: #908CAA">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #908CAA; font-style: italic">//</span><span style="color: #6E6A86; font-style: italic"> Register the shortcode</span></span>
<span class="line"><span style="color: #EA9A97">add_shortcode</span><span style="color: #908CAA">(</span><span style="color: #F6C177">&#39;last_10_posts&#39;</span><span style="color: #908CAA">,</span><span style="color: #E0DEF4"> </span><span style="color: #F6C177">&#39;last_10_posts_shortcode&#39;</span><span style="color: #908CAA">);</span></span></code></pre></div>



<p></p>



<h2 class="wp-block-heading" id="troubleshooting-shortcodes">Troubleshooting Shortcodes</h2>



<p>If a shortcode isn&#8217;t working:</p>



<ul class="wp-block-list">
<li>Double-check the syntax, including spelling and attributes</li>



<li>Ensure the plugin or theme providing the shortcode is active</li>



<li>Check if the shortcode requires any specific setup or configuration</li>
</ul>



<h2 class="wp-block-heading" id="best-practices">Best Practices</h2>



<ol start="8" class="wp-block-list"></ol>



<ul class="wp-block-list">
<li>Don&#8217;t overuse shortcodes; they can make your content harder to read and edit</li>



<li>Keep a list of the shortcodes you frequently use for easy reference</li>



<li>Always preview your content to ensure shortcodes are rendering correctly</li>
</ul>



<p>There is <a href="https://codex.wordpress.org/shortcode" target="_blank" rel="noreferrer noopener">additional information</a> on the WordPress site.</p>



<p>By following these steps, you should be able to effectively use shortcodes created by others in your WordPress site, enhancing its functionality and appearance without needing to write complex code yourself.</p>



<p>Good luck!</p>



<p></p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>S3 DeleteObject &#8211; How to Delete Multiple S3 Objects with NodeJS</title>
		<link>https://blog.gravyware.com/s3-deleteobject-for-multiple-s3-objects</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Fri, 27 Oct 2023 14:39:19 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=3332</guid>

					<description><![CDATA[Sometimes, you may need to delete multiple objects from an S3 bucket efficiently.  Here's how we did it using S3 DeleteObjects and NodeJS.]]></description>
										<content:encoded><![CDATA[
<p>Do you have a lot of random files in an S3 bucket that need to be deleted? We had about 12,000 random PDF files that needed to be deleted. They were mixed in with legitimate files and folders, so we needed a way to target specific files and bulk delete them easily.</p>



<p>Sometimes, you may need to delete multiple objects from an S3 bucket efficiently.  Here&#8217;s how we did it using S3 DeleteObjects and NodeJS.</p>


<div class="kb-row-layout-wrap kb-row-layout-id3332_9a4e60-ae alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column3332_449396-e8 kb-section-dir-vertical inner-column-1"><div class="kt-inside-inner-col"><p class="kt-adv-heading3332_f88f21-75 wp-block-kadence-advancedheading kt-adv-heading-has-icon" data-kb-block="kb-adv-heading3332_f88f21-75"><span class="kb-svg-icon-wrap kb-adv-heading-icon kb-svg-icon-fe_info kb-adv-heading-icon-side-left"><svg viewBox="0 0 24 24"  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="8"/></svg></span><span class="kb-adv-text-inner">This code will be run from your local computer.</span></p></div></div>

</div></div>


<p></p>





<p></p>



<h2 class="wp-block-heading">Assumptions</h2>



<ol class="wp-block-list">
<li>You have some experience with Node.js and can set up your development environment.</li>



<li>You know what &#8220;S3&#8221; and &#8220;IAM&#8221; are without looking them up.</li>



<li>You understand that mass deleting files can be crazy stressful, yet satisfying.</li>



<li>You understand that you are responsible for what you do.</li>
</ol>



<p>Do you fit these criteria?  Good, let&#8217;s keep going.</p>



<h2 class="wp-block-heading">Your AWS Environment Requirements</h2>



<p>Before you can start using the <a href="https://aws.amazon.com/sdk-for-javascript/" target="_blank" rel="noreferrer noopener">AWS SDK for JavaScript</a> to delete S3 objects, you need to make sure you have some information regarding your AWS environment:</p>



<ol class="wp-block-list">
<li><strong>AWS Account</strong>: You&#8217;ll need to have access to the AWS account.</li>



<li><strong>IAM User</strong>: <a href="https://www.msp360.com/resources/blog/how-to-find-your-aws-access-key-id-and-secret-access-key/" target="_blank" rel="noreferrer noopener nofollow">You&#8217;ll need an IAM</a> (Identity and Access Management) user with the necessary permissions for accessing and deleting objects in the S3 bucket.  You need their Access Keys.</li>



<li><strong>S3 Bucket</strong>: You&#8217;ll need to know which S3 bucket you want to delete objects from. Make sure the IAM user has the required permissions for this bucket.</li>
</ol>



<h2 class="wp-block-heading">Installing and Configuring the AWS SDK for JavaScript</h2>



<p>To use the AWS SDK for JavaScript, you need to install it and configure your AWS credentials. If you haven&#8217;t already installed Node.js and npm (Node Package Manager), make sure to do that first.</p>



<h3 class="wp-block-heading">Installation</h3>



<p>You can install the AWS SDK for JavaScript using npm:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(251, 251, 239, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">JavaScript</span><span role="button" tabindex="0" data-code="npm install @aws-sdk/client-s3" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F6F6F4">npm install @</span><span style="color: #62E884; font-style: italic">aws</span><span style="color: #F286C4">-</span><span style="color: #62E884; font-style: italic">sdk</span><span style="color: #F286C4">/</span><span style="color: #62E884; font-style: italic">client</span><span style="color: #F286C4">-</span><span style="color: #62E884; font-style: italic">s3</span></span></code></pre></div>



<p>Also, because we&#8217;re dealing with credentials, you&#8217;ll want to install <a href="https://www.npmjs.com/package/dotenv-safe" target="_blank" rel="noreferrer noopener nofollow">dotenv-safe</a>.</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">JavaScript</span><span role="button" tabindex="0" data-code="npm install @dotenv-safe" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F6F6F4">npm install @</span><span style="color: #62E884; font-style: italic">dotenv</span><span style="color: #F286C4">-</span><span style="color: #62E884; font-style: italic">safe</span></span></code></pre></div>



<p></p>



<p>Alrighty.  Let&#8217;s do this.</p>



<h3 class="wp-block-heading">Configuration</h3>



<p>There are three main files in this lesson.  They could have been combined into a single file, but separating them simplifies things a bit.</p>



<figure class="wp-block-kadence-image kb-image3332_82fda5-a1 size-full"><img loading="lazy" decoding="async" width="632" height="160" src="https://blog.gravyware.com/wp-content/uploads/2023/10/s3-deleting-multiple-objects.jpg" alt="the files needed to use the s3 deleteobject command" class="kb-img wp-image-3351" srcset="https://blog.gravyware.com/wp-content/uploads/2023/10/s3-deleting-multiple-objects.jpg 632w, https://blog.gravyware.com/wp-content/uploads/2023/10/s3-deleting-multiple-objects-300x76.jpg 300w" sizes="auto, (max-width: 632px) 100vw, 632px" /></figure>



<p>After installing the SDK, you must configure it with your AWS credentials. The AWS SDK for JavaScript will use these credentials to interact with your AWS services.</p>



<p>You can configure the SDK credentials using the <strong>dotenv-safe</strong> library.  Create a file named &#8220;.env&#8221; and update the lines below with your credentials and bucket information:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(251, 251, 239, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">.env</span><span role="button" tabindex="0" data-code="# credentials
S3_REGION = &quot;us-east-1&quot;
ACCESS_KEY_ID = &quot;AKIX8S45D49DJDH7JUNG&quot;
SECRET_ACCESS_KEY = &quot;f6+wDCaGIadoLdxlsE3d8DsnRv02c7jgo2&quot;

# bucket info.  Leave &quot;S3_FOLDER&quot; value blank if you want to start at the top level
S3_BUCKET = &quot;yourBucketName&quot;
S3_FOLDER = &quot;&quot;" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F6F6F4"># credentials</span></span>
<span class="line"><span style="color: #F6F6F4">S3_REGION </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">us-east-1</span><span style="color: #DEE492">&quot;</span></span>
<span class="line"><span style="color: #F6F6F4">ACCESS_KEY_ID </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">AKIX8S45D49DJDH7JUNG</span><span style="color: #DEE492">&quot;</span></span>
<span class="line"><span style="color: #F6F6F4">SECRET_ACCESS_KEY </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">f6+wDCaGIadoLdxlsE3d8DsnRv02c7jgo2</span><span style="color: #DEE492">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4"># bucket info.  Leave </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">S3_FOLDER</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4"> value blank </span><span style="color: #F286C4">if</span><span style="color: #F6F6F4"> you want to start at the top level</span></span>
<span class="line"><span style="color: #F6F6F4">S3_BUCKET </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">yourBucketName</span><span style="color: #DEE492">&quot;</span></span>
<span class="line"><span style="color: #F6F6F4">S3_FOLDER </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;&quot;</span></span></code></pre></div>



<p>In this script:</p>



<ul class="wp-block-list">
<li>Line 1-4: Your IAM credentials with proper permissions</li>



<li>Line 7: S3 bucket name</li>



<li>Line 8: Folder (S3 calls it a &#8220;Prefix&#8221;) below the bucket listed on line 7.  Add a value here only if you want to limit the script to search and delete from this folder (and below).</li>
</ul>



<h2 class="wp-block-heading">Listing Out the S3 Objects to be Deleted</h2>



<p>Now that your environment is set up and the AWS SDK is configured, let&#8217;s explore how to first list out the S3 objects you want to list.  Once we limit the list to what we want, we can go on to the next step and delete them.</p>



<p>Here&#8217;s how I went about listing the files I wanted to delete:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(251, 251, 239, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">list-all-s3-files.js</span><span role="button" tabindex="0" data-code="//this file lists the objects in an S3 bucket.  Max rows is 1000.

import 'dotenv/config';
import { S3Client, ListObjectsV2Command } from &quot;@aws-sdk/client-s3&quot;;

let client = new S3Client({
    region: process.env.S3_REGION,
    credentials: {
        accessKeyId: process.env.ACCESS_KEY_ID,
        secretAccessKey: process.env.SECRET_ACCESS_KEY
    }
});

const command = new ListObjectsV2Command({
    Bucket: process.env.S3_BUCKET,
    Prefix: process.env.S3_FOLDER,
    MaxKeys: 1000,
});

(async () =&gt; {

    const response = await client.send(command);

    // if you want to limit this list, add code here to change the &quot;response&quot; variable to only include files that fit

        //EXAMPLE 1 - reduce list to items between two dates
            // Define the date range for filtering
            //const startDate = new Date('2022-1-1');
            //const endDate = new Date('2023-1-1');
            // Filter the &quot;Contents&quot; array
            //const filteredContents = response.Contents.filter(item =&gt; {
            //    const lastModifiedDate = new Date(item.LastModified);
            //    return lastModifiedDate &gt;= startDate &amp;&amp; lastModifiedDate &lt;= endDate;
            //});
            // Update the &quot;Contents&quot; property in the response object
            //response.Contents = filteredContents;
        //EXAMPLE 1 END

        //EXAMPLE 2 - reduce file list to items with &quot;150&quot; in the file name
            const filteredContents = response.Contents.filter(item =&gt; item.Key.includes(&quot;150&quot;));
            // Update the &quot;Contents&quot; property in the response object
            response.Contents = filteredContents;
        //EXAMPLE 2 END

    //at this point we have the results in a single variable(&quot;response&quot;) with LastModified, Size, and StorageClass attributes included
    //console.log(response); //uncomment to see the full list

    // We just want the filename so we limit this list to get just the &quot;Key&quot; values
    const keys = response.Contents.map(item =&gt; item.Key).map(item =&gt; ({ Key: item }));
    console.log(keys);

})();

" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #7B7F8B">//this file lists the objects in an S3 bucket.  Max rows is 1000.</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F286C4">import</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&#39;</span><span style="color: #E7EE98">dotenv/config</span><span style="color: #DEE492">&#39;</span><span style="color: #F6F6F4">;</span></span>
<span class="line"><span style="color: #F286C4">import</span><span style="color: #F6F6F4"> { S3Client, ListObjectsV2Command } </span><span style="color: #F286C4">from</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">@aws-sdk/client-s3</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F286C4">let</span><span style="color: #F6F6F4"> client </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">S3Client</span><span style="color: #F6F6F4">({</span></span>
<span class="line"><span style="color: #F6F6F4">    region</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">S3_REGION</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">    credentials</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"><span style="color: #F6F6F4">        accessKeyId</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">ACCESS_KEY_ID</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">        secretAccessKey</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">SECRET_ACCESS_KEY</span></span>
<span class="line"><span style="color: #F6F6F4">    }</span></span>
<span class="line"><span style="color: #F6F6F4">});</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> command </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">ListObjectsV2Command</span><span style="color: #F6F6F4">({</span></span>
<span class="line"><span style="color: #F6F6F4">    Bucket</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">S3_BUCKET</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">    Prefix</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">S3_FOLDER</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">    MaxKeys</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #BF9EEE">1000</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">});</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">(</span><span style="color: #F286C4">async</span><span style="color: #F6F6F4"> () </span><span style="color: #F286C4">=&gt;</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> response </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">await</span><span style="color: #F6F6F4"> client.</span><span style="color: #62E884">send</span><span style="color: #F6F6F4">(command);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #7B7F8B">// if you want to limit this list, add code here to change the &quot;response&quot; variable to only include files that fit</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">        </span><span style="color: #7B7F8B">//EXAMPLE 1 - reduce list to items between two dates</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">// Define the date range for filtering</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//const startDate = new Date(&#39;2022-1-1&#39;);</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//const endDate = new Date(&#39;2023-1-1&#39;);</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">// Filter the &quot;Contents&quot; array</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//const filteredContents = response.Contents.filter(item =&gt; {</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//    const lastModifiedDate = new Date(item.LastModified);</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//    return lastModifiedDate &gt;= startDate &amp;&amp; lastModifiedDate &lt;= endDate;</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//});</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">// Update the &quot;Contents&quot; property in the response object</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">//response.Contents = filteredContents;</span></span>
<span class="line"><span style="color: #F6F6F4">        </span><span style="color: #7B7F8B">//EXAMPLE 1 END</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">        </span><span style="color: #7B7F8B">//EXAMPLE 2 - reduce file list to items with &quot;150&quot; in the file name</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> filteredContents </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> response.Contents.</span><span style="color: #62E884">filter</span><span style="color: #F6F6F4">(</span><span style="color: #FFB86C; font-style: italic">item</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">=&gt;</span><span style="color: #F6F6F4"> item.Key.</span><span style="color: #62E884">includes</span><span style="color: #F6F6F4">(</span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">150</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">));</span></span>
<span class="line"><span style="color: #F6F6F4">            </span><span style="color: #7B7F8B">// Update the &quot;Contents&quot; property in the response object</span></span>
<span class="line"><span style="color: #F6F6F4">            response.Contents </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> filteredContents;</span></span>
<span class="line"><span style="color: #F6F6F4">        </span><span style="color: #7B7F8B">//EXAMPLE 2 END</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #7B7F8B">//at this point we have the results in a single variable(&quot;response&quot;) with LastModified, Size, and StorageClass attributes included</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #7B7F8B">//console.log(response); //uncomment to see the full list</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #7B7F8B">// We just want the filename so we limit this list to get just the &quot;Key&quot; values</span></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> keys </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> response.Contents.</span><span style="color: #62E884">map</span><span style="color: #F6F6F4">(</span><span style="color: #FFB86C; font-style: italic">item</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">=&gt;</span><span style="color: #F6F6F4"> item.Key).</span><span style="color: #62E884">map</span><span style="color: #F6F6F4">(</span><span style="color: #FFB86C; font-style: italic">item</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">=&gt;</span><span style="color: #F6F6F4"> ({ Key</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> item }));</span></span>
<span class="line"><span style="color: #F6F6F4">    console.</span><span style="color: #62E884">log</span><span style="color: #F6F6F4">(keys);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">})();</span></span>
<span class="line"></span>
<span class="line"></span></code></pre></div>



<p>In this script:</p>



<ul class="wp-block-list">
<li>Line 3-4: Import the libraries</li>



<li>Line 6-12: Create the connection to AWS and authenticate using the credentials in your <strong>.env</strong> file</li>



<li>Line 14-18: Create the command that you&#8217;ll send to AWS to retrieve all S3 objects</li>



<li>Line 22: Send the request to AWS and put the values returned in the &#8220;<strong>response</strong>&#8221; variable</li>



<li>Line 26-37: Example code if you want to reduce the file list based on dates</li>



<li>Line 39-43: Example code if you want to reduce the file list based on a text value in the file name.  Comment out if not needed</li>



<li>Line 49: This line extracts the file name (&#8220;<strong>Key</strong>&#8220;) value from the JavaScript object returned and puts it in a format to copy for deletion.</li>



<li>Line 50: Logs the list of Keys in the console.</li>
</ul>



<p>Run this script alone to get the full list of objects to be deleted.</p>



<h2 class="wp-block-heading">Deleting Multiple Objects With S3 DeleteObject</h2>



<p>Now that you have the file list you want to delete, let&#8217;s explore how to delete multiple S3 objects efficiently. To delete multiple objects, you can use the <strong>deleteObjects</strong> method provided by the AWS SDK for JavaScript.</p>



<p>Here&#8217;s a sample script to delete multiple objects from an S3 bucket:</p>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(251, 251, 239, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#333545;color:#ebebe6">delete-multiple-s3-files.js</span><span role="button" tabindex="0" data-code="import 'dotenv/config';
import { DeleteObjectsCommand, S3Client } from &quot;@aws-sdk/client-s3&quot;;

let client = new S3Client({
    region: process.env.S3_REGION,
    credentials: {
        accessKeyId: process.env.ACCESS_KEY_ID,
        secretAccessKey: process.env.SECRET_ACCESS_KEY
    }
});

const command = new DeleteObjectsCommand({
    Bucket: process.env.S3_BUCKET,
    Delete: {
        Objects: [
            {Key: &quot;my-random-image.jpg&quot;}, // if in a directory: &quot;directory_name/file.ext&quot;
            {Key: &quot;wp-content/uploads/2022/08/19185558/some-other-random-image.jpg&quot;},
            {Key: &quot;wp-content/uploads/2023/05/19182148/another-random-image.jpg&quot;}
        ],
    }
});

(async () =&gt; {

    const response = await client.send(command);
    console.log(response);

})();
" style="color:#f6f6f4;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula-soft" style="background-color: #282A36" tabindex="0"><code><span class="line"><span style="color: #F286C4">import</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&#39;</span><span style="color: #E7EE98">dotenv/config</span><span style="color: #DEE492">&#39;</span><span style="color: #F6F6F4">;</span></span>
<span class="line"><span style="color: #F286C4">import</span><span style="color: #F6F6F4"> { DeleteObjectsCommand, S3Client } </span><span style="color: #F286C4">from</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">@aws-sdk/client-s3</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F286C4">let</span><span style="color: #F6F6F4"> client </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">S3Client</span><span style="color: #F6F6F4">({</span></span>
<span class="line"><span style="color: #F6F6F4">    region</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">S3_REGION</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">    credentials</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"><span style="color: #F6F6F4">        accessKeyId</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">ACCESS_KEY_ID</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">        secretAccessKey</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">SECRET_ACCESS_KEY</span></span>
<span class="line"><span style="color: #F6F6F4">    }</span></span>
<span class="line"><span style="color: #F6F6F4">});</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> command </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4; font-weight: bold">new</span><span style="color: #F6F6F4"> </span><span style="color: #62E884">DeleteObjectsCommand</span><span style="color: #F6F6F4">({</span></span>
<span class="line"><span style="color: #F6F6F4">    Bucket</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> process.env.</span><span style="color: #BF9EEE">S3_BUCKET</span><span style="color: #F6F6F4">,</span></span>
<span class="line"><span style="color: #F6F6F4">    Delete</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"><span style="color: #F6F6F4">        Objects</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> [</span></span>
<span class="line"><span style="color: #F6F6F4">            {Key</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">my-random-image.jpg</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">}, </span><span style="color: #7B7F8B">// if in a directory: &quot;directory_name/file.ext&quot;</span></span>
<span class="line"><span style="color: #F6F6F4">            {Key</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">wp-content/uploads/2022/08/19185558/some-other-random-image.jpg</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">},</span></span>
<span class="line"><span style="color: #F6F6F4">            {Key</span><span style="color: #F286C4">:</span><span style="color: #F6F6F4"> </span><span style="color: #DEE492">&quot;</span><span style="color: #E7EE98">wp-content/uploads/2023/05/19182148/another-random-image.jpg</span><span style="color: #DEE492">&quot;</span><span style="color: #F6F6F4">}</span></span>
<span class="line"><span style="color: #F6F6F4">        ],</span></span>
<span class="line"><span style="color: #F6F6F4">    }</span></span>
<span class="line"><span style="color: #F6F6F4">});</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">(</span><span style="color: #F286C4">async</span><span style="color: #F6F6F4"> () </span><span style="color: #F286C4">=&gt;</span><span style="color: #F6F6F4"> {</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">    </span><span style="color: #F286C4">const</span><span style="color: #F6F6F4"> response </span><span style="color: #F286C4">=</span><span style="color: #F6F6F4"> </span><span style="color: #F286C4">await</span><span style="color: #F6F6F4"> client.</span><span style="color: #62E884">send</span><span style="color: #F6F6F4">(command);</span></span>
<span class="line"><span style="color: #F6F6F4">    console.</span><span style="color: #62E884">log</span><span style="color: #F6F6F4">(response);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F6F6F4">})();</span></span>
<span class="line"></span></code></pre></div>



<p>I&#8217;ve purposely kept this script&#8217;s object list manual since I didn&#8217;t want anyone to inadvertently delete more than they wanted.  It&#8217;s easy enough to automate yourself, or <a href="https://blog.gravyware.com/contact" target="_blank" data-type="link" data-id="https://blog.gravyware.com/contact" rel="noreferrer noopener">you can ask me</a> how to do it.</p>



<p>You&#8217;ll want to replace your list with the list I have on<strong> lines 16-18</strong>.  Just specify the directory and filename.</p>



<p>In this script:</p>



<ul class="wp-block-list">
<li>Line 1-2: Import the libraries</li>



<li>Line 4-10: Create the connection to AWS and authenticate using the credentials in your <strong>.env</strong> file</li>



<li>Line 12-21: Create the command that you&#8217;ll send to AWS to define which S3 objects to delete</li>



<li><mark style="background-color:rgba(0, 0, 0, 0);color:#ff0000" class="has-inline-color">Line 16-18</mark>: Replace these lines with the full list of the files you want deleted.  You would have this list from the response that &#8220;<strong>list-all-s3-files.js</strong>&#8221; returned.  <strong>Make sure it&#8217;s formatted correctly</strong>.</li>



<li>Line 23-28: Send the delete request to AWS and display the response in the console.</li>
</ul>



<p>Run this script alone and all items you listed should get deleted.</p>



<h2 class="wp-block-heading">Summary</h2>



<p>This is a quick and easy way to efficiently delete multiple S3 objects using the AWS SDK for JavaScript in your Node.js application. This can be particularly useful for automating cleanup tasks and managing your S3 resources more effectively.</p>



<p>Also, if you want information on how to set up<a href="https://blog.gravyware.com/what-is-ec2-setup-a-web-server-tutorial-in-aws"> your own web server in AWS</a>, we&#8217;ve done that plenty of times too!</p>



<p>Good luck!</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>HiLiter &#8211; Highlight Your Brand &#038; URL On Every Website</title>
		<link>https://blog.gravyware.com/hiliter-highlighter-chrome-extension</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Thu, 22 Dec 2022 18:51:36 +0000</pubDate>
				<category><![CDATA[Products]]></category>
		<category><![CDATA[Communication]]></category>
		<category><![CDATA[Marketing]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=2673</guid>

					<description><![CDATA[Hiliter is the perfect Chrome extension for highlighting your brand and website on every webpage. You'll never have to search for your links or keywords again!]]></description>
										<content:encoded><![CDATA[
<p>We released a quick Chrome browser extension that we built for internal use, but perhaps it will assist you also.</p>



<p><strong>It&#8217;s free</strong>, so please try it out and let us know if it helps you as well.</p>



<p class="has-medium-font-size"><a href="https://hiliter.co" target="_blank" rel="noreferrer noopener">https://hiliter.co</a></p>



<h2 class="wp-block-heading">The Problem We Needed to Fix</h2>



<p>We were always coming across mentions of our products in articles that we knew nothing about.  It got us wondering how many other mentions we were missing and knew nothing about.  We were spending a lot of time reading through articles and social media and forums because we didn&#8217;t want to &#8220;miss&#8221; someone commenting about our products.</p>



<p>We also wanted an easier way to track our product mentions in news sites and forums. We spend so much time sifting through posts that we needed a better way.  We were probably missing someone writing about our business or bypassing links that someone has pointed to you.</p>



<p>Scrolling through endless social media posts is exhausting and impossible to digest everything.&nbsp; I just want to find the posts that mention my product and company name.&nbsp; This results in a lot of wasted time, which is why we developed Hiliter Chrome extension. This chrome extension will immediately highlight your keywords and links whenever they exist on any website you visit.</p>



<h2 class="wp-block-heading">The Solution</h2>



<p>With HiLiter Chrome extension, you&#8217;ll be able to save time by never having to search for your links or keywords again. You&#8217;ll be able to scroll quickly and only stop on those areas that contain your keywords and links.</p>


<div class="kb-gallery-wrap-id-_c73444-85 alignnone wp-block-kadence-advancedgallery"><div class="kb-gallery-ul kb-gallery-non-static kb-gallery-type-thumbslider kb-gallery-id-_c73444-85 kb-gallery-caption-style-bottom-hover kb-gallery-filter-none" data-image-filter="none" data-lightbox-caption="true"><div class="kt-blocks-carousel kt-carousel-container-dotstyle-dark"><div id="kb-slider-_c73444-85" class="kt-blocks-carousel-init splide kb-blocks-slider kt-carousel-arrowstyle-whiteondark kt-carousel-dotstyle-dark kb-slider-group-arrow kb-slider-arrow-position-center" data-columns-xxl="4" data-columns-xl="4" data-columns-md="4" data-columns-sm="4" data-columns-xs="4" data-columns-ss="4" data-slider-anim-speed="400" data-slider-scroll="1" data-slider-arrows="true" data-slider-fade="true" data-slider-dots="false" data-slider-hover-pause="false" data-slider-type="thumbnail" data-slider-nav="kb-thumb-slider-_c73444-85"  data-slider-auto="" data-slider-speed="7000" data-slider-gap="10px" data-slider-gap-tablet="10px" data-slider-gap-mobile="10px" data-show-pause-button="false"><div class="splide__track"><ul class="splide__list"><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-item"><div class="kadence-blocks-gallery-item-inner"><figure class="kb-gallery-figure kadence-blocks-gallery-item-hide-caption"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png" data-id="2676" class="wp-image-2676 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-item"><div class="kadence-blocks-gallery-item-inner"><figure class="kb-gallery-figure kadence-blocks-gallery-item-hide-caption"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png" data-id="2679" class="wp-image-2679 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-item"><div class="kadence-blocks-gallery-item-inner"><figure class="kb-gallery-figure kadence-blocks-gallery-item-hide-caption"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png" data-id="2678" class="wp-image-2678 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-item"><div class="kadence-blocks-gallery-item-inner"><figure class="kb-gallery-figure kadence-blocks-gallery-item-hide-caption"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png" data-id="2677" class="wp-image-2677 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li></ul></div></div><div id="kb-thumb-slider-_c73444-85" class="kb-blocks-slider splide kt-carousel-arrowstyle-whiteondark kt-carousel-dotstyle-dark" data-slider-anim-speed="400" data-slider-scroll="1" data-slider-arrows="true" data-slider-fade="true" data-slider-dots="false" data-slider-hover-pause="false" data-slider-speed="7000" data-slider-type="thumbnail" data-slider-nav="kb-slider-_c73444-85"><div class="splide__track"><ul class="splide__list"><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-thumb-item"><div class="kadence-blocks-gallery-thumb-item-inner"><figure class="kb-gallery-figure"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png" data-id="2676" class="wp-image-2676 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-15-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-thumb-item"><div class="kadence-blocks-gallery-thumb-item-inner"><figure class="kb-gallery-figure"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png" data-id="2679" class="wp-image-2679 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-13-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-thumb-item"><div class="kadence-blocks-gallery-thumb-item-inner"><figure class="kb-gallery-figure"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png" data-id="2678" class="wp-image-2678 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-14-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li><li class="kb-slide-item kb-gallery-carousel-item splide__slide"><div class="kadence-blocks-gallery-thumb-item"><div class="kadence-blocks-gallery-thumb-item-inner"><figure class="kb-gallery-figure"><div class="kb-gal-image-radius"><div class="kb-gallery-image-contain kadence-blocks-gallery-intrinsic kb-gallery-image-ratio-land32 kb-has-image-ratio-land32" ><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png" width="1280" height="800" alt="Hiliter Chrome extension screenshot" data-full-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png" data-light-image="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png" data-id="2677" class="wp-image-2677 skip-lazy" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16.png 1280w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16-300x188.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16-1024x640.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/screenshot-rocks-16-768x480.png 768w" sizes="auto, (max-width: 1280px) 100vw, 1280px" /></div></div></figure></div></div></li></ul></div></div></div></div></div>


<h3 class="wp-block-heading">Potential Users</h3>



<ul class="wp-block-list">
<li><strong>Marketing Agencies</strong> &#8211; It&#8217;s an easy way for you to keep tabs on customer mentions in articles/forums</li>



<li><strong>PR Firms</strong></li>



<li><strong>OEMs</strong></li>



<li><strong>Brand Managers</strong></li>



<li><strong>SEO Specialists</strong>
<ul class="wp-block-list">
<li>Where are you mentioned?&nbsp; Where are your links on a page?&nbsp; Are they NOFOLLOW links?</li>
</ul>
</li>



<li><a href="https://blog.gravyware.com/best-venture-capital-firms" target="_blank" rel="noreferrer noopener">Venture Capital Firms</a>
<ul class="wp-block-list">
<li>Keep track of your investment mentions.</li>
</ul>
</li>
</ul>



<p><strong>It&#8217;s free</strong>, so please try it out and let us know if you find it useful.</p>



<p class="has-large-font-size"><a href="https://hiliter.co" target="_blank" rel="noreferrer noopener">https://hiLiter.co</a></p>



<p>Thanks!</p>



<p></p>



<h2 class="wp-block-heading">You Might Also Like</h2>



<ul class="wp-block-list">
<li><a href="https://blog.gravyware.com/the-best-startup-blogs-to-grow-your-business" data-type="post" data-id="2246">Follow These 48 best startup blogs to quickly grow your SaaS Business</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Follow These 48 best startup blogs to quickly grow your SaaS Business (2023)</title>
		<link>https://blog.gravyware.com/the-best-startup-blogs-to-grow-your-business</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Wed, 19 Oct 2022 19:14:35 +0000</pubDate>
				<category><![CDATA[Communication]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Marketing]]></category>
		<category><![CDATA[SaaS]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=2246</guid>

					<description><![CDATA[To help the new startup founder out, we've put together a list of some of the best startup blogs that you should be following if you're looking to grow your SaaS startup.   All are centered on helping tech companies succeed in the business world and their respective startup industry.]]></description>
										<content:encoded><![CDATA[
<p>We all know how important it is to stay up-to-date with the latest startup news and trends. But with so many tech startup blogs out there, it can be tough to know which ones are worth reading.</p>



<p>To help the new startup founder out, we&#8217;ve put together a list of some of the best startup blogs that you should be following if you&#8217;re looking to grow your SaaS startup.  Some are blogs of software and internet companies, but many are independent media sites.  All are centered on helping tech companies succeed in the business world and their respective startup industry.</p>



<p>If you&#8217;re looking for tech news about other tech startups, there is plenty to choose from as well. The list below is for expanding your knowledge and learning new techniques that will be useful for your business (and maybe a few tech news sites).  We&#8217;ve put them into categories, but they do seem to overlap in places.</p>



<p>Hopefully, they will save you some time in your entrepreneurial adventure. The need to maintain relevant information is critical – particularly given that the changing world has changed dramatically.</p>



<p>Let us know if we missed a blog that you think should be added.</p>





<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>Digital Marketing</strong> Startup Blogs</h2>



<p>Digital marketing is the process of using digital channels to promote or market products and services to target customers. Channels include social media, email, search engines, websites, and mobile apps.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="384" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-25-1024x384.png" alt="digital marketing startup blogs" class="wp-image-2261" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-25-1024x384.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-25-300x112.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-25-768x288.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-25-1536x576.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-25.png 1595w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The startup marketing blogs we recommend are:</p>



<h3 class="wp-block-heading">1) <u><a href="https://www.marketingcharts.com/" target="_blank" rel="noreferrer noopener nofollow">Marketing Charts</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="555" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-32-1024x555.png" alt="marketingcharts.com screenshot" class="wp-image-2291" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-32-1024x555.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-32-300x163.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-32-768x416.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-32-1536x833.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-32.png 1594w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>MarketingCharts is first and foremost a hub of marketing data, graphics, and analyses.  They are a leading data source cited by many of the top news agencies.  Did you know that <a href="https://www.marketingcharts.com/digital/social-media-227454" target="_blank" rel="noreferrer noopener nofollow">YouTube usage by adults is on the rise</a>?  I did because I read this site.</p>



<p>This is also a great resource if you need information for a blog post or presentation deck.  The site is updated multiple times per week.</p>



<h3 class="wp-block-heading">2) <a href="https://www.cmswire.com/" target="_blank" rel="noreferrer noopener nofollow"><u>CMSWire</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="826" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-33-1024x826.png" alt="CMSWire screenshot" class="wp-image-2293" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-33-1024x826.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-33-300x242.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-33-768x620.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-33.png 1294w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>They obsess over the evolving digital customer experience, customer data, and digital experience optimization universe.</p>



<p>This site is updated daily.</p>



<h3 class="wp-block-heading">3) <u><a href="https://contentmarketinginstitute.com/blog/" target="_blank" rel="noreferrer noopener nofollow">Content Marketing Institute</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="922" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-34-1024x922.png" alt="Content Marketing Institute screenshot" class="wp-image-2295" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-34-1024x922.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-34-300x270.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-34-768x691.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-34.png 1103w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>As the name suggests, CMI is all about content marketing. They provide helpful resources, tips, and advice on how to create and market engaging content that will attract and convert leads into customers.</p>



<p>The site is updated daily.</p>



<h3 class="wp-block-heading">4) <u><a href="https://econsultancy.com/articles/" target="_blank" rel="noreferrer noopener nofollow">Econsultancy</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="771" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-35-1024x771.png" alt="econsultancy screenshot" class="wp-image-2297" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-35-1024x771.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-35-300x226.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-35-768x578.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-35.png 1380w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The latest articles on global digital marketing and e-commerce from Econsultancy’s award-winning analysts and experts.</p>



<p>This site is updated a few times per week.</p>



<h3 class="wp-block-heading">5) <a href="https://martech.org/" target="_blank" rel="noreferrer noopener nofollow"><u>MarTech</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="615" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-36-1024x615.png" alt="MarTech screenshot" class="wp-image-2299" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-36-1024x615.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-36-300x180.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-36-768x461.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-36.png 1493w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>MarTech is on a mission to educate marketers about marketing technology and strategy through news and feature reporting, newsletters, research reports, live conferences, and digital events.</p>



<p>This site is updated multiple times per day.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>Technology &amp; Tech News</strong> Startup Blogs</h2>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="471" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-26-1024x471.png" alt="technology and tech news blogs" class="wp-image-2263" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-26-1024x471.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-26-300x138.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-26-768x353.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-26.png 1297w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>We have to see what&#8217;s going on outside of our own business from time to time. Here are the sites we frequently read:</p>



<h3 class="wp-block-heading">1) <a href="https://hackernoon.com/" target="_blank" rel="noreferrer noopener nofollow"><u>HackerNoon</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="530" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-37-1024x530.png" alt="HackerNoon screenshot" class="wp-image-2301" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-37-1024x530.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-37-300x155.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-37-768x398.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-37-1536x796.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-37.png 1892w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>How hackers start their afternoon. HackerNoon is a free platform with 25k+ contributing writers. 100M+ humans have visited HackerNoon to learn about technology.</p>



<p>HackerNoon is updated multiple times per day.</p>



<h3 class="wp-block-heading">2) <a href="https://www.forentrepreneurs.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">ForEntrepreneurs</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="827" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-38-1024x827.png" alt="forEntrepreneurs screenshot" class="wp-image-2303" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-38-1024x827.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-38-300x242.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-38-768x620.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-38.png 1286w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Run by David Skok, a Venture Capitalist with Matrix Partners.  There is a wealth of great articles here that will give you every advantage you need to succeed.</p>



<p>The site is well laid-out and the articles are well written.</p>



<h3 class="wp-block-heading">3) <a href="https://techcrunch.com/" target="_blank" rel="noreferrer noopener"><span style="text-decoration: underline;">TechCrunch</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="674" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-39-1024x674.png" alt="TechCrunch screenshot" class="wp-image-2306" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-39-1024x674.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-39-300x198.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-39-768x506.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-39-1536x1012.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-39.png 1564w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>TechCrunch has been around for a long time and remains one of the best sources for tech news. They report on the business of technology, startups, venture capital funding, and Silicon Valley in general.</p>



<p>Many updates are made throughout the day on this site.</p>



<h3 class="wp-block-heading">4) <a href="https://readwrite.com/" target="_blank" rel="noreferrer noopener nofollow"><u>ReadWrite</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="568" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-41-1024x568.png" alt="readwrite screenshot" class="wp-image-2309" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-41-1024x568.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-41-300x167.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-41-768x426.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-41-1536x853.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-41.png 1870w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Self-described as &#8220;The Blog of Things&#8221;.  ReadWrite writes articles slanted toward the tech-savvy reader.</p>



<p>This site is updated daily.<br></p>



<h3 class="wp-block-heading">5) <a href="https://www.vox.com/recode" target="_blank" rel="noreferrer noopener nofollow"><u>Recode</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="923" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-42-1024x923.png" alt="recode screenshot" class="wp-image-2312" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-42-1024x923.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-42-300x270.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-42-768x692.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-42.png 1086w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The tech column of Vox Media. Recode explores how the digital world is changing — from keeping Big Tech accountable to explaining how decisions in Silicon Valley affect your daily life.</p>



<p>Recode is updated daily.<br></p>



<h3 class="wp-block-heading">6) <a href="https://venturebeat.com/" target="_blank" rel="noreferrer noopener nofollow"><u>VentureBeat</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="668" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-43-1024x668.png" alt="" class="wp-image-2314" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-43-1024x668.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-43-300x196.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-43-768x501.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-43.png 1299w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>VentureBeat covers transformative tech. They help business leaders make smarter decisions.</p>



<p>This site is updated many times per day.<br></p>



<h3 class="wp-block-heading">7) <a href="https://gigaom.com/" target="_blank" rel="noreferrer noopener nofollow"><u>GigaOm</u></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="787" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-44-1024x787.png" alt="GigaOm screenshot" class="wp-image-2317" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-44-1024x787.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-44-300x231.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-44-768x590.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-44.png 1348w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>GigaOm provides research from engineering-led practitioners to help you innovate, upskill, and be ready for what’s next.</p>



<p>You will spend a lot of time wading through all the information on this site.<br></p>



<h3 class="wp-block-heading">8) <a href="https://arstechnica.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">Ars Technica</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="766" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-45-1024x766.png" alt="Ars Technica screenshot" class="wp-image-2319" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-45-1024x766.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-45-300x225.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-45-768x575.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-45.png 1296w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Serving the Technologist for more than a decade. A combination of IT news, reviews, and analysis.  We love this site.</p>



<p>Ars Technica is updated many times per day.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>SEO</strong> Startup Blogs</h2>



<p>SEO (Search Engine Optimization) is the process of optimizing a website for Google search with the goal of earning higher web traffic levels and improving the visibility of the site. A strong SEO strategy can also help to improve conversion rates by making it easier for potential customers to find your website.</p>



<p>SEO strategies focus on improving both on-page and off-page ranking factors. On-page SEO tactics include optimizing title tags, meta descriptions, and header tags. Off-page SEO tactics include link-building and social media engagement.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="433" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-27-1024x433.png" alt="SEO Startup blogs" class="wp-image-2265" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-27-1024x433.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-27-300x127.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-27-768x324.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-27.png 1077w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Staying on top of Google&#8217;s constantly changing algorithm is critical. These blogs can help you with that.</p>



<h3 class="wp-block-heading">1) <a href="https://blog.gravyware.com/recommends/surfer-seo" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">Surfer SEO</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="697" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-78-1024x697.png" alt="Surfer SEO blog screenshot" class="wp-image-2436" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-78-1024x697.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-78-300x204.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-78-768x523.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-78.png 1516w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Surfer is our go-to tool for SEO purposes.  Their blog is solid information about on-page, content creation &amp; SEO tips.</p>



<p>They generally provide new tips a few times a month and it will often include instructions on how their tool can make things easier (which it does).</p>



<h3 class="wp-block-heading">2) <u><a href="https://moz.com/blog" target="_blank" rel="noreferrer noopener nofollow">The Moz</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="894" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-46-1024x894.png" alt="The Moz Blog screenshot" class="wp-image-2321" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-46-1024x894.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-46-300x262.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-46-768x671.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-46.png 1190w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The industry&#8217;s top wizards, doctors, and other experts offer their best advice, research, how-tos, and insights—all in the name of helping you level up your SEO and online marketing skills.</p>



<p>This site is updated every few days.</p>



<h3 class="wp-block-heading">3) <u><a href="https://neilpatel.com/blog/" target="_blank" rel="noreferrer noopener nofollow">Neil Patel</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="832" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-47-1024x832.png" alt="Neil Patel screenshot" class="wp-image-2323" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-47-1024x832.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-47-300x244.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-47-768x624.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-47.png 1203w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Neil Patel is regarded as one of the most knowledgeable SEO experts out there.  He has great articles and can help analyze your website to identify SEO errors, keyword opportunities, and competition.</p>



<p>His site isn&#8217;t updated daily, but there are a lot of articles to go through.</p>



<h3 class="wp-block-heading">4) <u><a href="https://rankmath.com/blog/" target="_blank" rel="noreferrer noopener nofollow">RankMath Blog</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="871" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-48-1024x871.png" alt="RankMath blog screenshot" class="wp-image-2325" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-48-1024x871.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-48-300x255.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-48-768x654.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-48.png 1222w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>One of the best WordPress plugins for SEO brings you one of the best blogs as well. Their SEO blog provides you with tutorials and guides on how to improve SEO and take your rankings to the next level.  They have quite a few extensive tutorials.</p>



<p>This site is updated weekly or so.</p>



<h3 class="wp-block-heading">5) <a href="https://copyblogger.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">CopyBlogger</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="858" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-49-1024x858.png" alt="CopyBlogger screenshot" class="wp-image-2327" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-49-1024x858.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-49-300x251.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-49-768x643.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-49.png 1231w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Their tagline is &#8220;We Help Writers Succeed in the Creator Economy&#8221;.  So few people can really write well which is why we frequent this blog.  The insights you get from these articles are empowering and enlightening.  Your SEO will benefit greatly from improved content, and this blog helps with that.</p>



<p>This site is updated a few times per week.</p>



<p></p>



<h3 class="wp-block-heading">6) <a href="https://copyblogger.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">Ahrefs Blog</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="785" src="https://blog.gravyware.com/wp-content/uploads/2022/12/image-1024x785.png" alt="Ahrefs Blog Screenshot" class="wp-image-2624" srcset="https://blog.gravyware.com/wp-content/uploads/2022/12/image-1024x785.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/12/image-300x230.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/12/image-768x589.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/12/image.png 1203w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Ahrefs is a critical tool for SEO purposes.  Their entire business helps you rank higher in Google.  You&#8217;ll find a wealth of information here on how to rank higher and how their tool can help you save time.</p>



<p>They&#8217;ll typically use videos in order to help with their blog posts.</p>



<p>This site is updated a few times per week.</p>



<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>Email / SMS Marketing</strong> Startup Blogs</h2>



<p>Email Marketing is one of the most effective ways to reach your target audience and build relationships with them. Email Marketing can also help you to increase brand awareness, drive traffic to your website, and generate leads.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="512" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-28-1024x512.png" alt="email marketing startup blogs" class="wp-image-2266" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-28-1024x512.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-28-300x150.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-28-768x384.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-28.png 1153w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">1) <u><a href="https://www.litmus.com/blog/" target="_blank" rel="noreferrer noopener nofollow">Litmus</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="702" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-50-1024x702.png" alt="Litmus blog screenshot" class="wp-image-2329" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-50-1024x702.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-50-300x206.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-50-768x526.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-50.png 1318w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Get email best practices, how-tos, and more in the Litmus blog.  There&#8217;s a lot of them here.</p>



<p>There are new articles and tutorials every few days.</p>



<h3 class="wp-block-heading">2) <u><a href="https://sendgrid.com/blog/" target="_blank" rel="noreferrer noopener nofollow">SendGrid</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="670" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-51-1024x670.png" alt="SendGrid blog screenshot" class="wp-image-2331" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-51-1024x670.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-51-300x196.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-51-768x502.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-51-1536x1004.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-51.png 1589w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Read the SendGrid blog (The Full Send) to learn how to maximize your customer reach, and how to fully take advantage of the capabilities that SendGrid offers.</p>



<p>There are new articles every week or so.</p>



<h3 class="wp-block-heading">3) <u><a href="https://blog.emailoctopus.com/" target="_blank" rel="noreferrer noopener nofollow">Email Octopus</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="930" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-52-1024x930.png" alt="email octopus screenshot" class="wp-image-2333" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-52-1024x930.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-52-300x273.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-52-768x698.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-52.png 1127w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Email tips, inspiration, and insights from the team at EmailOctopus​. They want to make email marketing easier for you and have articles and case studies.</p>



<p>The blog updates have slowed down recently, and are now updated about once a month.</p>



<h3 class="wp-block-heading">4) <u><a href="https://blog.aweber.com/" target="_blank" rel="noreferrer noopener nofollow">AWeber</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="930" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-53-1024x930.png" alt="AWeber screenshot" class="wp-image-2335" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-53-1024x930.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-53-300x272.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-53-768x698.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-53.png 1145w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Find a wealth of valuable advice, tips, and tricks to grow your email list, increase sales, improve your emails, and landing pages, and so much more.</p>



<p>New articles are added and updated every couple of days.</p>



<h3 class="wp-block-heading">5) <u><a href="https://mailchimp.com/resources/email/" target="_blank" rel="noreferrer noopener nofollow">Mailchimp</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="669" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-54-1024x669.png" alt="mailchimp blog screenshot" class="wp-image-2338" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-54-1024x669.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-54-300x196.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-54-768x502.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-54.png 1446w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>From one of the biggest email software providers.  This is less of a blog and more of a knowledge base.  Get advice on creating and sending effective campaigns.</p>



<p>We&#8217;re not sure of the frequency that new articles are added, although the information seems updated.</p>



<h3 class="wp-block-heading">6) <u><a href="https://www.theemailmarketers.com/blog" target="_blank" rel="noreferrer noopener nofollow">The Email Marketers</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="849" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-55-1024x849.png" alt="The Email Marketers screenshot" class="wp-image-2340" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-55-1024x849.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-55-300x249.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-55-768x637.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-55.png 1241w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Get the latest email marketing strategies and techniques in e-commerce to grow your online sales while automizing your workflows.</p>



<p>Updates are a bit sporadic.  They seem to be about every month or so.</p>



<h3 class="wp-block-heading">7) <u><a href="https://designmodo.com/articles/" target="_blank" rel="noreferrer noopener nofollow">Designmodo</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="647" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-56-1024x647.png" alt="designmodo screenshot" class="wp-image-2342" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-56-1024x647.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-56-300x190.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-56-768x485.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-56-1536x971.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-56.png 1647w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Mostly design-centric articles to help your email design skills. They help you get better at web design and email marketing: detailed tutorials and guides, case studies, and opinions from industry professionals.</p>



<p>You can see new articles roughly every week or so.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase">Social Media Startup Blogs</h2>



<p>The best Social Media blogs provide readers with useful, actionable tips and advice on a wide range of topics related to social media. They offer a place for readers to connect with other like-minded individuals, share their own experiences, and learn from the successes and failures of others. And of course, they&#8217;re updated often with fresh content.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="490" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-29-1024x490.png" alt="social media startup blogs" class="wp-image-2267" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-29-1024x490.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-29-300x144.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-29-768x368.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-29.png 1107w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Here are some we like:</p>



<h3 class="wp-block-heading">1) <a href="https://www.socialmediatoday.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">SocialMediaToday</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="778" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-76-1024x778.png" alt="Social Media Today screenshot" class="wp-image-2414" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-76-1024x778.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-76-300x228.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-76-768x584.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-76.png 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The latest news, trends, and tips in social media.  If it revolves around social media, it&#8217;s probably here.</p>



<p>They provide daily updates.</p>



<h3 class="wp-block-heading">2) <a href="https://www.socialmediaexaminer.com" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">Social Media Examiner</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="856" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-57-1024x856.png" alt="social media examiner screenshot" class="wp-image-2344" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-57-1024x856.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-57-300x251.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-57-768x642.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-57.png 1247w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Their tagline is &#8220;Your Guide to the Social Media Jungle&#8221;.  They help millions of marketers discover how to best use social media marketing to connect with customers, generate awareness, and increase sales.  You&#8217;re going to learn something every time you go here.</p>



<p>Expect new articles every day.</p>



<h3 class="wp-block-heading">3) <a href="https://www.thesocialmediahat.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">The Social Media Hat</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="633" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-77-1024x633.png" alt="The Social Media Hat screenshot" class="wp-image-2417" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-77-1024x633.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-77-300x185.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-77-768x475.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-77.png 1341w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Founded by Mike Allton in 2011, The Social Media Hat is an award-winning resource for businesses around the world. Here you’ll find guides to plan successful virtual events, reviews of the best tools, and in-depth articles on social media strategies and tactics.</p>



<p>It is updated approximately every month or so.</p>



<h3 class="wp-block-heading">4) <a href="https://www.jeffbullas.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">Jeff Bullas</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="866" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-58-1024x866.png" alt="Jeff Bullas screenshot" class="wp-image-2346" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-58-1024x866.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-58-300x254.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-58-768x650.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-58.png 1225w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Helping business and personal brands with digital marketing including social media with Blogs, Twitter, Facebook, LinkedIn, YouTube, and Search Engine Optimization.  Their goal is &#8220;To optimize your brand in a digital world&#8221;.</p>



<p>He seems to update the site every week or so.</p>



<h3 class="wp-block-heading">5) <a href="https://adespresso.com/blog/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">AdEspresso</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="927" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-59-1024x927.png" alt="AdEspresso screenshot" class="wp-image-2348" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-59-1024x927.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-59-300x272.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-59-768x695.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-59.png 1150w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Owned by HootSuite.  They claim that their blog is the best resource to stay up to date with Facebook &amp; Google Ads news and tactics for successful campaigns that convert!</p>



<p>They seem to update the site with a new article every week or so.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>Finance / Legal / Venture Capital</strong> Startup Blogs</h2>



<p>Financing your startup can be complicated and tiresome. If you are in this phase, you probably have plenty of questions.  Be sure to view our list of <a href="https://blog.gravyware.com/best-venture-capital-firms">best venture capital firms</a>.   <a href="https://blog.gravyware.com/top-venture-capital-firms" data-type="post" data-id="1110">The top Venture Capitalists</a> provide funding for early-stage startups and help them to grow and scale their businesses.</p>



<figure class="wp-block-kadence-image kb-image_222a15-18 size-large"><img loading="lazy" decoding="async" width="1024" height="543" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-30-1024x543.png" alt="finance and venture capital startup blogs" class="kb-img wp-image-2269" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-30-1024x543.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-30-300x159.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-30-768x407.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-30.png 1271w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Some of the best blogs for more information can be found below.</p>



<h3 class="wp-block-heading">1) <u><a href="https://www.securedocs.com/blog" target="_blank" rel="noreferrer noopener nofollow">SecureDocs</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="889" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-60-1024x889.png" alt="SecureDocs blog screenshot" class="wp-image-2350" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-60-1024x889.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-60-300x260.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-60-768x667.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-60.png 1183w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Stay on top of the latest tips, trends, and best practices for M&amp;A, fundraising, and other business events.</p>



<h3 class="wp-block-heading">2) <u><a href="http://redrocketvc.blogspot.com/" target="_blank" rel="noreferrer noopener nofollow">Red Rocket VC</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="876" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-61-1024x876.png" alt="Red Rocket VC screenshot" class="wp-image-2352" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-61-1024x876.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-61-300x257.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-61-768x657.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-61.png 1206w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Red Rocket can help your business &#8220;blast off&#8221;!! Our Partners are proven CEOs and CMOs, that have already mastered the same growth challenges you are experiencing. They can help you with your growth strategy, execution, or financing needs such as venture capital. Check out their free e-books such as &#8220;101 Startup Lessons&#8221;.</p>



<p>Updates occur every month or so on this site.</p>



<h3 class="wp-block-heading">3) <a href="https://a16z.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">Andreessen Horowitz</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="677" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-73-1024x677.png" alt="Andreesseen Horowitz (a16z) screenshot" class="wp-image-2379" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-73-1024x677.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-73-300x198.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-73-768x507.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-73.png 1338w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Commonly referred to as &#8220;a16z&#8221;, this is the blog/site of one of the biggest Venture Capital firms in Silicon Valley.  There&#8217;s a lot of wealth in these articles, and they are updated daily.  Check out their podcast as well.  Good stuff.</p>



<p>They have updates daily on this site.</p>



<h3 class="wp-block-heading">4) <a href="https://review.firstround.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">First Round Review</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="544" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-74-1024x544.png" alt="First Round Review screenshot" class="wp-image-2381" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-74-1024x544.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-74-300x159.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-74-768x408.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-74-1536x815.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-74.png 1716w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>This is a startup blog from First Round Capital and is made up of mostly guest posts from experts in their field.</p>



<p>There&#8217;s a wealth of great information here, and the articles are well-written.</p>



<h3 class="wp-block-heading">5) <a href="https://tomtunguz.com/" target="_blank" rel="noreferrer noopener nofollow">Tomasz Tunguz</a></h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="870" height="897" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-75.png" alt="Tomasz Tunguz screenshot" class="wp-image-2383" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-75.png 870w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-75-291x300.png 291w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-75-768x792.png 768w" sizes="auto, (max-width: 870px) 100vw, 870px" /></figure>



<p>Tomasz Tunguz is a VC at Redpoint and writes a blog post or two each week.  Topics include how to raise funds, KPIs that matter, and other questions that startup founders might need answering.</p>



<p>The articles are to the point and without the fluff.  Just the way we like it.</p>



<h3 class="wp-block-heading">6) <u><a href="https://www.onstartups.com/" target="_blank" rel="noreferrer noopener nofollow">OnStartups</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="760" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-68-1024x760.png" alt="OnStartups screenshot" class="wp-image-2368" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-68-1024x760.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-68-300x223.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-68-768x570.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-68.png 1398w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Dharmesh Shah maintains this site.  He&#8217;s an Angel Investor, and co-founder of HubSpot.  He knows what he&#8217;s doing.</p>



<p>This one has waned a bit with the updates, with only three new blog posts in 2022. It still has a wealth of information that is still very relevant.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>Startup</strong> News Sources</h2>



<p>While it&#8217;s important to see what the rest of the world is doing, we typically hit these once a day or so.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="523" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-31-1024x523.png" alt="startup news sources" class="wp-image-2271" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-31-1024x523.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-31-300x153.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-31-768x392.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-31.png 1275w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">1) <a href="https://techcrunch.com/" target="_blank" rel="noreferrer noopener nofollow"><span style="text-decoration: underline;">TechCrunch</span></a></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="674" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-40-1024x674.png" alt="TechCrunch screenshot" class="wp-image-2307" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-40-1024x674.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-40-300x198.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-40-768x506.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-40-1536x1012.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-40.png 1564w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>TechCrunch has been around for a long time and remains one of the best sources for tech news. They report on the business of technology, startups, venture capital funding, and Silicon Valley in general.</p>



<p>If you want to know the details of what&#8217;s happening in the world of tech the minute it happens, this site is for you.</p>



<h3 class="wp-block-heading">2) <u><a href="https://www.youngupstarts.com/" target="_blank" rel="noreferrer noopener nofollow">Young Upstarts</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="1019" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-62-1024x1019.png" alt="Young Startups screenshot" class="wp-image-2355" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-62-1024x1019.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-62-300x300.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-62-150x150.png 150w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-62-768x764.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-62.png 1045w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Young Upstarts is an online business resource for startup entrepreneurs, small business owners, idea people, and intrapreneurs seeking change within their organizations.</p>



<p>They have daily updates on this site.</p>



<h3 class="wp-block-heading">3) <u><a href="https://startups.microsoft.com/en-US/blog/" target="_blank" rel="noreferrer noopener nofollow">Microsoft for Startups Blog</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="652" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-63-1024x652.png" alt="Microsoft for Startups blog screenshot" class="wp-image-2357" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-63-1024x652.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-63-300x191.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-63-768x489.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-63-1536x978.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-63.png 1584w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Learn from founders who’ve been there before. Accelerate your startup with Microsoft for Startups Founders Hub.</p>



<p>There are many good articles here that often help you use Microsoft products.  Surprise!  Many of the guest authors have partnered with Microsoft.</p>



<h3 class="wp-block-heading">4) <u><a href="https://startupnation.com/" target="_blank" rel="noreferrer noopener nofollow">StartupNation</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="821" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-64-1024x821.png" alt="StartupNation screenshot" class="wp-image-2359" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-64-1024x821.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-64-300x241.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-64-768x616.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-64.png 1301w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Want to learn how to start a business? StartupNation has the resources you need to ensure your success.</p>



<p>This is a great resource that is updated daily.</p>



<h3 class="wp-block-heading">5) <u><a href="https://www.techstars.com/the-line" target="_blank" rel="noreferrer noopener nofollow">Tech Stars</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="634" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-65-1024x634.png" alt="TechStars The Line screenshot" class="wp-image-2361" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-65-1024x634.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-65-300x186.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-65-768x476.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-65-1536x951.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-65.png 1665w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Techstars is a global platform for investment and innovation. They connect entrepreneurs, investors, and corporations.&nbsp;This blog contains ideas &amp; insights from the Techstars network.</p>



<p>There are many sections to this blog, and most seem to be updated every week or so.</p>



<h3 class="wp-block-heading">6) <u><a href="https://thestartupmag.com/" target="_blank" rel="noreferrer noopener nofollow">The Startup Magazine</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="664" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-66-1024x664.png" alt="The Startup Magazine screenshot" class="wp-image-2363" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-66-1024x664.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-66-300x194.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-66-768x498.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-66.png 1208w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The Startup Magazine aspires to educate and inspire startups. They provide advice, access to business tools, and tell great entrepreneur stories.</p>



<p>It&#8217;s not our favorite layout, but the site is updated pretty much daily.</p>



<h3 class="wp-block-heading">7) <u><a href="https://www.killerstartups.com/" target="_blank" rel="noreferrer noopener nofollow">Killer Startups</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="804" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-67-1024x804.png" alt="killerstartups screenshot" class="wp-image-2365" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-67-1024x804.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-67-300x236.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-67-768x603.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-67.png 1307w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Great place to showcase your app and read articles from other founders.</p>



<p>Update daily with shorter, to-the-point articles.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase"><strong>International</strong> Startup News Sources</h2>



<h3 class="wp-block-heading">1) <u><a href="https://magazine.startus.cc/" target="_blank" rel="noreferrer noopener nofollow">StartUs Magazine</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="954" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-69-1024x954.png" alt="StartUs Magazine screenshot" class="wp-image-2369" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-69-1024x954.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-69-300x279.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-69-768x715.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-69.png 1111w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Europe&#8217;s leading source on daily happenings in the startup community, reaching over 400.000 people monthly.</p>



<p>This blog/site has a section for pretty much every area a startup founder may need, and it&#8217;s updated daily.</p>



<h3 class="wp-block-heading">2) <u><a href="https://yourstory.com/" target="_blank" rel="noreferrer noopener nofollow">YourStory</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="804" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-70-1024x804.png" alt="YourStory screenshot" class="wp-image-2371" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-70-1024x804.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-70-300x236.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-70-768x603.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-70.png 1166w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>This is India&#8217;s biggest platform dedicated to fostering the startup ecosystem via entrepreneurship-related stories, resources, products, research reports, and more.</p>



<p>It&#8217;s updated daily.</p>



<h3 class="wp-block-heading">3) <u><a href="https://startups.co.uk/" target="_blank" rel="noreferrer noopener nofollow">Startups.</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="658" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-71-1024x658.png" alt="Startups. screenshot" class="wp-image-2373" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-71-1024x658.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-71-300x193.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-71-768x493.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-71-1536x986.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-71.png 1615w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Starting a business? Startups is the UK’s leading independent, online resource for anyone starting and growing a business. Find independent advice, tools, events, and information for new businesses, start-ups, small businesses, and ambitious entrepreneurs.</p>



<p>It&#8217;s updated daily for the most part.</p>



<h3 class="wp-block-heading">4) <u><a href="https://e27.co/" target="_blank" rel="noreferrer noopener nofollow">e27</a></u></h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="923" src="https://blog.gravyware.com/wp-content/uploads/2022/10/image-72-1024x923.png" alt="e27 screenshot" class="wp-image-2375" srcset="https://blog.gravyware.com/wp-content/uploads/2022/10/image-72-1024x923.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-72-300x270.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-72-768x692.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/10/image-72.png 1152w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Get access to insights, updates, and resources that let you learn more and connect with investors and startups in Southeast Asia.</p>



<p>The site is well laid out, and updated daily.</p>



<p></p>



<h2 class="wp-block-heading" style="text-transform:uppercase">Conclusion</h2>



<p>There you have it! These are some of the best startup blogs that you should be reading if you&#8217;re looking to grow your SaaS startup.</p>



<p>Please let us know your thoughts and if we missed any!</p>



<p></p>



<h2 class="wp-block-heading">You Might Also Like</h2>



<ul class="wp-block-list">
<li><a href="https://blog.gravyware.com/best-social-proof-tools-to-improve-your-business" data-type="post" data-id="2017">The 21 Best Social Proof Tools to Improve Your Business</a></li>
</ul>



<div class="wp-block-kadence-column kadence-column_e6036c-58 inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-column kadence-column_08a9b5-2b kb-section-dir-horizontal inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-icon kt-svg-icons kt-svg-icons_484c34-cc alignnone kb-icon-valign-middle">
<div class="kt-svg-style-default kt-svg-icon-wrap kt-svg-item-_7d698a-68"><span class="kb-svg-icon-wrap kb-svg-icon-fe_info"><svg viewBox="0 0 24 24"  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="8"/></svg></span></div>
</div>



<span class="kt-adv-heading_d5ff3f-a3 wp-block-kadence-advancedheading" data-kb-block="kb-adv-heading_d5ff3f-a3">Disclosure</span>
</div></div>



<p>Some of the links in this article may be affiliate links, which can provide compensation to me at no cost to you if you decide to purchase the product.</p>
</div></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What is EC2 and How To Easily Setup Your Own Web Server In AWS Cloud (2025)</title>
		<link>https://blog.gravyware.com/what-is-ec2-setup-a-web-server-tutorial-in-aws</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Sun, 18 Sep 2022 23:58:14 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[SaaS]]></category>
		<category><![CDATA[Server Monitoring]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=1788</guid>

					<description><![CDATA[What is EC2?  Your step-by-step guide to quickly launching a cloud-based EC2 web server at AWS.  After reading this, you'll be able to deploy your own web server in just a few minutes (or less)!]]></description>
										<content:encoded><![CDATA[<div class="kb-row-layout-wrap kb-row-layout-id1788_11d322-f9 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_d05ad2-b8 inner-column-1"><div class="kt-inside-inner-col"><div class="kb-row-layout-wrap kb-row-layout-id1788_60b920-02 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-2-columns kt-row-layout-right-golden kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top kb-theme-content-width">

<div class="wp-block-kadence-column kadence-column1788_140b27-2f inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-icon kt-svg-icons kt-svg-icons1788_435619-b0 alignnone">
<div class="wp-block-kadence-single-icon kt-svg-style-default kt-svg-icon-wrap kt-svg-item-1788_e97927-d4"><span class="kb-svg-icon-wrap kb-svg-icon-fe_thumbsUp"><svg viewBox="0 0 24 24"  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><path d="M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"/></svg></span></div>
</div>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_bb7f5f-d0 inner-column-2"><div class="kt-inside-inner-col">
<p>Your step-by-step AWS EC2 tutorial for quickly launching a web server at AWS</p>
</div></div>

</div></div></div></div>

</div></div>


<p>Launching a new web server at AWS (Amazon&#8217;s cloud service) can be a daunting and confusing process. There are many things to consider, from choosing the right platform to configuring security settings.</p>



<p>We&#8217;re going to explain what is EC2 and cloud computing. Then we&#8217;re going to show you how to launch a web server in Amazon Web Services(AWS cloud services) in just 10 minutes. We&#8217;ll walk you through the steps, and provide tips for optimizing your setup.&nbsp; We’ve removed all the noise and provided you with the core details so you can have your own server set up correctly in a very short time.</p>





<h2 class="wp-block-heading">What is Amazon EC2?</h2>



<p>Amazon EC2 stands for Amazon Elastic Compute Cloud. It&#8217;s the service on Amazon Web Services that allows you to &#8220;create and rent&#8221; a virtual server (or Virtual Machine).&nbsp; AWS cloud allows you to create, replicate, update, and delete server instances in minutes.  Through your AWS account, you can create on-demand instances using scalable computing capacity.  You can scale your entire organization&#8217;s infrastructure with a simplicity that did not exist just a few short years ago.</p>



<p>Perhaps you&#8217;d like to create a new AI tool that utilizes OpenAI&#8217;s GPT-3 engine.  Then creating an Amazon EC2 instance is a good place to start.</p>



<h2 class="wp-block-heading">Amazon EC2 Pricing</h2>



<p>For this demonstration, we&#8217;ll be using the Free-Tier setup for most options, so the cost will be near zero.  Please understand that &#8220;Free-tier&#8221; doesn&#8217;t always mean absolutely free.  There are limits to what is free and these limits are set pretty low.  From the Amazon EC2 website:</p>



<figure class="wp-block-pullquote has-border-color has-theme-palette-7-border-color has-small-font-size" style="border-style:solid;border-width:5px;border-radius:31px"><blockquote><p>As part of the AWS Free Tier, you can get started with Amazon EC2 for free. This includes 750 hours of Linux and Windows t2.micro instances (t3.micro for the regions in which t2.micro is unavailable), each month for one year. To stay within the Free Tier, use only EC2 Micro instances.</p><cite>https://aws.amazon.com/ec2/pricing/</cite></blockquote></figure>



<p></p>



<p>If you need to &#8220;guesstimate&#8221; your costs for your server instances, Amazon has an <a href="https://calculator.aws/#/" target="_blank" rel="noreferrer noopener">AWS Pricing Calculator</a> that will help you.  Obviously, overall costs will depend on the horsepower of the virtual machine you set up and for how long you keep it running.</p>



<h2 class="wp-block-heading">Features of Amazon EC2</h2>



<ul class="wp-block-list">
<li><strong>Scalable computing capacity</strong> &#8211; Amazon EC2 allows you to increase or decrease capacity in minutes</li>



<li><strong>You have complete control</strong> &#8211; you have complete control of your instances</li>



<li><strong>Reliability</strong> &#8211; You are using Amazon&#8217;s cloud computing experience and their virtual servers architecture.</li>



<li><strong>Secure</strong> &#8211; Amazon&#8217;s infrastructure is one of the most secure systems in the world.</li>



<li><strong>Inexpensive</strong> &#8211; You can create an Amazon EC2 server instance and only use it (and be charged) for one hour per day.  Perhaps you want to create a proof of concept server instance for a few days and then delete it.  It&#8217;s simple, quick, and cheap to do that.</li>



<li><strong>Easy to begin</strong> &#8211; There&#8217;s no lengthy installation of software and manual handling of a server.  Everything is done via the Amazon Management Console website and takes minutes to complete.</li>
</ul>



<p>So there are numerous benefits to creating a cloud computing server instance in Amazon EC2.  Are you ready to get one set up quickly?  Let’s do this!</p>



<h2 class="wp-block-heading">Step 1: What Are Key Pairs</h2>



<figure class="wp-block-pullquote has-border-color has-theme-palette-7-border-color has-small-font-size" style="border-radius:31px;border-style:solid;border-width:5px"><blockquote><p>Key Pairs is how AWS authenticates you when you need to log into the server itself.</p><p><strong>They allow you root access to your servers</strong>.</p></blockquote></figure>



<p></p>



<p><strong>Technical Answer</strong>: Key pairs are used to authenticate SSH connections to your instances. A key pair, also known as a &#8220;.pem&#8221; file on Linux and Unix systems, consists of a private key and a public key. The private key is kept on your local computer and should be securely protected. The public key is uploaded to AWS cloud and placed on your Amazon EC2 (Amazon Elastic Compute Cloud) instance. When you connect to your instance using SSH, the client software presents the private key for authentication. If the server recognizes the public key that corresponds to the private key, it authenticates the connection.</p>



<p><strong>Simpler Answer</strong>: AWS uses a &#8220;Key Pair&#8221; combination that is unique to you for security access to pretty much everything AWS.  You need to create this combination (which we show you first) in order to control your web server.</p>



<p>The Key Pair is completely separate from your username/password combination that you use to log in to the AWS web portal.&nbsp; AWS defines a Key Pair as so: &#8220;A key pair, consisting of a public key and a private key, is a set of security credentials that you use to prove your identity when connecting to an Amazon EC2 instance.&#8221;</p>



<p>The Key Pairs is how AWS makes sure you are who you say you are.&nbsp; <strong>It allows you root access to your servers, which means <em>full administrative access</em></strong>.&nbsp; Do not lose these or share them with strangers.</p>



<h3 class="wp-block-heading"><strong>Create Your Key Pairs</strong></h3>



<ol class="wp-block-list">
<li>Sign up for an AWS account using the AWS Management Console(or sign in if you already have an AWS account) at <a href="https://aws.mazon.com" target="_blank" rel="noreferrer noopener">https://aws.amazon.com</a></li>



<li>In the Search Bar at the top of the page, search for “EC2” or &#8220;Elastic Compute Cloud&#8221;.&nbsp; Click on the result that says “Virtual Servers in the Cloud”.&nbsp; It should be the top result.&nbsp; Click on it.&nbsp; Currently, it’s located at https://console.aws.amazon.com/ec2/</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/rbkZfiwLJvgzoq4poEthI-6uH6ZX1aDNz9b0DfV6lHY9HriKmczzr7Vv2OQeQKd6A6GQ2nzY7gW1o9EKvdPgg5T3MyfZcTN9yzFFaNm3m1AU4j2JGuXSP0IiCWuC0l4IcEakDy_ZXVUAxhSjB43WWy5qKhf1KVXpxWsnJxz9sEqEcnsIX0TBMB2F" alt="what is ec2"/></figure>



<ol class="wp-block-list">
<li>In the left navigation column, under &#8220;Network &amp; Security&#8221;, click on Key Pairs.</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/OGUxK2LCONp8YShJuT6xStG4NYrJd71F1nCWvyn2w64uYdcMWHWYIUDypNUetj2eqxonGzrZ5whOWCdNM97k2tQJT0yWAeblUTu3OWTtROiThWv4uEa6aaGf4faCywnNI2rZjBJEDeB03HQE3-w4E5atf-5LcLGUgSPoEBV67h0ZrQ6Lx4FJVLEi" alt="AWS key pairs"/></figure>



<ol class="wp-block-list">
<li>Click on the &#8220;Create key pair&#8221; button on the top right.</li>



<li>Use the following information:
<ol class="wp-block-list">
<li>Name: &#8220;My AWS Super Secret Key Pair&#8221;</li>



<li>Key pair type: &#8220;RSA&#8221;</li>



<li>Private key file format: &#8220;.pem&#8221;</li>
</ol>
</li>



<li>Hit the &#8220;Create key pair&#8221; button.</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/TNC3nD_sADGUd6vqPUdIfZ75-2cv5COUSEmDN3sfrvB1QNK4FScmcqr71tPfeH4CYFknRoLhNkliWUw-pVUvkSnPqkA7X_quHH-fTXVbIuyijkqfhbJg0wHshTfaS_Dy7MaEdmqGHvwIJV1xQsPTlg3BMeaKpws-ArQAxninBo_gqIWOVfbEX8az" alt="Create a key pair"/></figure>



<p>The file should automatically be downloaded to your computer.&nbsp; <strong>This is the only time that you&#8217;ll have access to this file</strong>.&nbsp; It will never be created again.&nbsp; Store it someplace safe.</p>


<div class="kb-row-layout-wrap kb-row-layout-id1788_33c2ab-69 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_9c0db4-cc kb-section-dir-vertical inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-column kadence-column1788_c085b4-65 inner-column-1"><div class="kt-inside-inner-col">
<span class="kt-adv-heading1788_b57ff6-e6 our-pick-arrow wp-block-kadence-advancedheading" data-kb-block="kb-adv-heading1788_b57ff6-e6"><mark class="kt-highlight">MAC or Linux Users</mark></span>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_dafbd6-38 inner-column-1"><div class="kt-inside-inner-col">
<p>Note to Mac or Linux computer users &#8211; you have to set this file so only you can read it.&nbsp; If you don’t do this, it won’t work correctly to connect to your server instance.&nbsp; To do this, follow the following two steps:</p>



<ol class="wp-block-list">
<li>Go to the directory where the .pem file is located.</li>



<li>Type “<strong>chmod 400 My AWS Super Secret Key Pair.pem</strong>” (replace with file name, of course).</li>



<li>Rest as this is now complete.</li>
</ol>
</div></div>
</div></div>

</div></div>


<p></p>



<h2 class="wp-block-heading">Step 2: <strong>Create an Amazon EC2 Instance</strong></h2>



<p>Now the fun part.  We get to create our own server and have it ready in a matter of minutes.  Let&#8217;s do this.</p>



<h3 class="wp-block-heading">Select the Region That Your Server Will Reside</h3>



<p>Select a region at the top right.&nbsp; This is the location that your Web Server will actually reside.&nbsp; In North America, just choose N. Virginia for this example.  Once we select the region, we don&#8217;t want to change it again during this tutorial.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="546" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSSelectRegion-1024x546.png" alt="Select your AWS Region" class="wp-image-1824" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSSelectRegion-1024x546.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSSelectRegion-300x160.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSSelectRegion-768x409.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSSelectRegion-1536x819.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSSelectRegion-2048x1092.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>A few things about AWS regions</strong>:</p>



<ol class="wp-block-list">
<li>Each AWS region is built to be isolated from all other AWS regions.&nbsp; This allows for the greatest possible fault tolerance and a high level of stability in the region.</li>



<li>If you have a majority cluster of end-users in a particular geographic location, you might choose to have your server close to them.</li>



<li>It’s also important to know that <strong>not all resources and functionality exist</strong> in every region.&nbsp; The isolation that exists means that AWS rolls out functionality to regions separately.</li>



<li>Also, your Console Home is specific to a Region.</li>
</ol>



<p></p>



<h3 class="wp-block-heading">Select an Amazon Machine Image (AMI)</h3>



<p>Let&#8217;s go back to the main Amazon EC2 page.  Search for EC2 in the search bar at the top of the page.</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/rbkZfiwLJvgzoq4poEthI-6uH6ZX1aDNz9b0DfV6lHY9HriKmczzr7Vv2OQeQKd6A6GQ2nzY7gW1o9EKvdPgg5T3MyfZcTN9yzFFaNm3m1AU4j2JGuXSP0IiCWuC0l4IcEakDy_ZXVUAxhSjB43WWy5qKhf1KVXpxWsnJxz9sEqEcnsIX0TBMB2F" alt="Select an AWS AMI"/></figure>



<p>Select &#8220;Instances&#8221; in the left-hand navigation.  This is the area where you will maintain all of your on-demand instances once they&#8217;re set up.  Go ahead and click on &#8220;Launch Instances&#8221; in the top right corner.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="427" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSLaunchInstance-1024x427.png" alt="Launch an Instance" class="wp-image-1832" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSLaunchInstance-1024x427.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSLaunchInstance-300x125.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSLaunchInstance-768x321.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSLaunchInstance-1536x641.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSLaunchInstance-2048x855.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>This next screen is where you will select the size and power of your server.</p>



<p>Start by naming your new server.  This is a name for display purposes, so make it easy.  I might name it: &#8220;Ubuntu with PHP #1&#8221;, or &#8220;Windows for C# Development&#8221;.  The name is actually a &#8220;tag&#8221;, and it can be altered later if you desire.</p>



<p>The next area is where you&#8217;ll be presented with AMI options.&nbsp; AMI stands for Amazon&#8217;s Machine Image, and these are basically pre-configured servers with various operating systems.&nbsp; Do you want a Microsoft Windows server or Linux or something else? This is when you make that decision.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="849" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMI-1024x849.png" alt="Choose an AMI" class="wp-image-1835" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMI-1024x849.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMI-300x249.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMI-768x637.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMI-1536x1274.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMI-2048x1699.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>We&#8217;ll stick with the &#8220;Quick Start&#8221; tab and click the box that represents the operating system you want running your server.  The drop-down box immediately below will change and give you the list of AMIs that Amazon recommends.  Free Tier is what we&#8217;ll use for this example.  These are great for development purposes or for simply learning AWS services.</p>



<p>I use both Windows-based servers and Linux-based servers.&nbsp; If you&#8217;re planning on running applications that need PHP and MySQL, then consider choosing one that has that pre-installed.&nbsp; But you can always install it afterward also&#8230;just trying to save you some time.&nbsp; When you&#8217;ve located the server AMI you want, select it in the drop-down.</p>



<p></p>


<div class="kb-row-layout-wrap kb-row-layout-id1788_63b7c7-66 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_818285-10 inner-column-1"><div class="kt-inside-inner-col"><div class="kb-row-layout-wrap kb-row-layout-id1788_d1d206-b3 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-2-columns kt-row-layout-right-golden kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top kb-theme-content-width">

<div class="wp-block-kadence-column kadence-column1788_ec1ad3-6b inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-icon kt-svg-icons kt-svg-icons1788_83b1a2-03 alignnone">
<div class="wp-block-kadence-single-icon kt-svg-style-default kt-svg-icon-wrap kt-svg-item-1788_0ae659-06"><span class="kb-svg-icon-wrap kb-svg-icon-fas_times-circle"><svg viewBox="0 0 512 512"  fill="currentColor" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"/></svg></span></div>
</div>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_c103bf-ef inner-column-2"><div class="kt-inside-inner-col">
<h4 class="wp-block-heading has-text-align-center"><meta charset="utf-8">Be Careful!</h4>



<p>If you search for a different AMI or click on &#8220;Browse more AMIs&#8221;, you&#8217;ll see a lot of configurations submitted by outside companies.&nbsp; They typically have a price associated with them that can be quite steep.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="992" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMIWarning-1024x992.png" alt="Be careful when choosing an AMI" class="wp-image-1836" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMIWarning-1024x992.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMIWarning-300x291.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMIWarning-768x744.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMIWarning-1536x1489.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSChooseAMIWarning-2048x1985.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p></p>
</div></div>

</div></div></div></div>

</div></div>


<h3 class="wp-block-heading">Select your Amazon EC2 Instance Type</h3>



<p>The next area is where you choose an Instance Type.&nbsp; This is the power behind the server.  Since we&#8217;re going for Free Tier, select &#8220;t1.micro&#8221; or &#8220;t2.micro&#8221; in the drop-down.</p>


<div class="kb-row-layout-wrap kb-row-layout-id1788_7b5349-b4 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_7300bc-21 kb-section-dir-vertical inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-column kadence-column1788_ae269b-c3 inner-column-1"><div class="kt-inside-inner-col">
<span class="kt-adv-heading1788_c2d1d3-b3 our-pick-arrow wp-block-kadence-advancedheading" data-kb-block="kb-adv-heading1788_c2d1d3-b3"><mark class="kt-highlight">Amazon EC2 Instance Types Explained</mark></span>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_79e240-71 inner-column-1"><div class="kt-inside-inner-col">
<p>What does &#8220;t2.micro&#8221; mean?  This is the size and horsepower of the instance you&#8217;re creating.  Small instances (micro) tend to be free and are not meant for a production environment.</p>



<p>EC2 server instances types comprise of varying combinations of CPU, memory, storage, and networking capacity and are designed to fit different use cases. When you launch an instance, you can select its type based on your requirements. Each Amazon EC2 instance type offers different computing, memory, and storage capabilities.</p>



<p>There are five families of EC2 instance types: General purpose, Compute-optimized, Memory-optimized, Storage-optimized, and Accelerated computing.</p>



<p>General purpose instances are a good choice for many applications. These instances offer a balance of computing, memory, and networking resources.</p>



<p>Compute-optimized instances are designed for compute-intensive applications that require high-performance processors.</p>



<p>Memory-optimized instances are designed for memory-intensive applications and offer high levels of memory and CPU.</p>



<p>Storage-optimized instances are designed for storage-intensive applications that require high levels of input/output operations per second (IOPS).</p>



<p>Accelerated computing instances use hardware accelerators, or co-processors, to perform functions more efficiently than is possible in software running on CPUs.</p>
</div></div>
</div></div>

</div></div>


<h3 class="wp-block-heading">Assign Your Key Pair</h3>



<p>Remember that Key Pair you created first?  You will need to assign to this instance at this point.&nbsp; Select the key pair from the drop-down that you just created.&nbsp; You&#8217;re almost done.</p>



<h3 class="wp-block-heading">Adjust Network Settings</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="975" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSNetworkSettings-1024x975.png" alt="Adjust your AWS Network Settings" class="wp-image-1842" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSNetworkSettings-1024x975.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSNetworkSettings-300x286.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSNetworkSettings-768x731.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSNetworkSettings-1536x1463.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSNetworkSettings-2048x1950.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Checkmark the two bottom boxes that say &#8220;Allow HTTPs traffic from the internet&#8221; and &#8220;Allow HTTP traffic from the internet&#8221;.</p>



<p>Finally, click on the orange &#8220;Launch Instance&#8221; button on the right.  Boom!&nbsp; Your server is being created!&nbsp; This will take a couple of minutes but we can continue with the configuration at the same time.</p>



<p></p>



<h2 class="wp-block-heading">Step 3: <strong>Add an Elastic IP to Your Server</strong></h2>



<p>Let&#8217;s assign an Elastic IP address to your server instance.</p>


<div class="kb-row-layout-wrap kb-row-layout-id1788_2b9dcd-aa alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_ac29c7-33 kb-section-dir-vertical inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-column kadence-column1788_6fe6ae-31 inner-column-1"><div class="kt-inside-inner-col">
<span class="kt-adv-heading1788_aba5a5-56 our-pick-arrow wp-block-kadence-advancedheading" data-kb-block="kb-adv-heading1788_aba5a5-56"><mark class="kt-highlight">WHAT Is An Elastic IP? </mark></span>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_c658f0-17 inner-column-1"><div class="kt-inside-inner-col">
<p>Elastic IP addresses are reserved public IP addresses<strong> that you can assign to any Amazon EC2 instance in a particular region until you choose to release it</strong>.&nbsp; It&#8217;s how you&#8217;ll access your server using FTP, Remote Desktop, SSH, etc. </p>



<p>You&#8217;ll also use this address as the main IP address for a website domain within DNS.</p>



<p>In short, it&#8217;s your<em> External IP address</em> for the server.</p>
</div></div>
</div></div>

</div></div>


<p></p>



<ol class="wp-block-list">
<li>In the left navigation column, under &#8220;Network &amp; Security&#8221;, click on Elastic IPs.</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/d_wLrk9S51kDfEaBYZ7utsdUM4uR-q6Kp_BQaTCCItxtGc3_TQDbRCf5Ur-Hr6XhXlfiHw7sfzx4YN4USItzCZSF7pusOBls9womsgSVNBcprKxF5BgzFQelKQT3Dg1OiZQVEEMBX_6DNKytFhoLXKycJ-Zcrfb_O2hEG7ICSGHSGt8e-xP-16WV" alt="Add an Elastic IP"/></figure>



<h3 class="wp-block-heading">OPTION 1</h3>



<p>Your screen will probably be blank, but if there are Elastic IP addresses allocated to your account, you&#8217;ll see some here.&nbsp; They won&#8217;t have an Associated Instance ID value in that column like below. <strong>&nbsp;If there are no values on this screen or no unassociated Instance IDs, jump to OPTION 2.</strong></p>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/h2meegeWwGed_J0tae4e69YSCnFOm3xUmttxi0FEx4whxyvurgiXhENXbUx57woWfr4HgLNFKC60Z0BU8mMJDeUFZyRPHrFEBgWszXYN85TKV6mqXw-V5pGW-iCnbaN5MIbI5MDvU8rOevZM-pXQiOMgii9_3dCD5h83OwBGmMkZGzBO-yujqsiS" alt="Add an Elastic IP"/></figure>



<p>You can use those Elastic IPs for your new server.&nbsp; Just click on the IP address, and then click on the &#8220;Associate Elastic IP address&#8221; button.</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/qxvsabaCmWvh9MY5WA3p2idsClQ3AB2ba1IsM0ku1Fe0_m52q5gV-zop2I8SUFsHHD3xymn-pOFw0FOtayBXFrPo_TY0BAR5pW01DSJ7AtQCgfnSxDEYIPwlxW4ecRWvN7DfWosuZdmk00z9bmJDfeOwqOoTwtfNGR-2U-ep40Ux4mH0una69tE4" alt="Add an Elastic IP"/></figure>



<p>&nbsp;Select an instance from the dropdown.&nbsp; The IP address then should populate in that respective field as well.&nbsp; You shouldn&#8217;t have to type anything in these fields.</p>



<p>Click on the &#8220;Associate&#8221; button at the bottom.&nbsp; You should be good to go.</p>



<h3 class="wp-block-heading">OPTION 2</h3>



<ol class="wp-block-list">
<li>From the main Elastic IP address screen, click on the &#8220;Allocate Elastic IP address&#8221; button in the top right corner of the main screen.</li>



<li>The next screen will populate with the correct information already.&nbsp; Use &#8220;Amazon&#8217;s pool of IPv4 addresses&#8221;.</li>



<li>Click on the &#8220;Allocate&#8221; button at the bottom.</li>



<li>You should see the screen below.&nbsp; Select an instance from the dropdown.&nbsp; The IP address then should populate in that respective field as well.&nbsp; You shouldn&#8217;t have to type anything in these fields.</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/CnVk3Hgfbrs2B7g1ZK-xLrSJPiCUGV3wbn9SKlHGTkyCjcpeYFReg9aRkpOBMECjwf6uDQaIACCAfQDPNApAQ3KHBHf62cNLEWuw_EmX-ye4b6zysVRlTFxFFQCzUmr-P2CaHGHk_qlYiPHD9GrtGAzPgvNyXpENYeY1DOhiLzIDeIkEbzzkUNme" alt="Associate an Elastic IP"/></figure>



<p>Click on &#8220;Associate&#8221; button at the bottom.&nbsp; You should be good to go.</p>


<div class="kb-row-layout-wrap kb-row-layout-id1788_a288e5-4d alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_d525b5-51 kb-section-dir-vertical inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-column kadence-column1788_40c0a3-a1 inner-column-1"><div class="kt-inside-inner-col">
<span class="kt-adv-heading1788_6bd813-5f our-pick-arrow wp-block-kadence-advancedheading" data-kb-block="kb-adv-heading1788_6bd813-5f"><mark class="kt-highlight">Note</mark></span>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_b82466-1a inner-column-1"><div class="kt-inside-inner-col">
<p>This Elastic IP address value is what you add as an &#8220;A&#8221; record within your DNS settings when you’re ready to point a domain to your new server.</p>
</div></div>
</div></div>

</div></div>


<p><span style="font-size: revert; color: var(--global-palette4);"></span></p>



<p></p>



<h2 class="wp-block-heading">Step 4: <strong>Add Security Groups to Your Server</strong></h2>



<p>You actually already added a few Security Groups when you created your server.</p>



<p>Creating a security group is just the first step to securing your instance.&nbsp; You have to give the security group rules in order for it to do anything.</p>



<ol class="wp-block-list">
<li>In the left navigation column, under &#8220;Network &amp; Security&#8221;, click on &#8220;Security Groups&#8221;.</li>
</ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/CJsU8p-pn-XdPm2Js3Rd_TacU_QmM_MNlsm2F8JWQqCVkNC_p0CFtudkY_LJ6JmhtU_aDaZYLFW5eUaKDj9fq55duGHS97iDS9ZH-JQAUIl5xxASzi6-rMb7j4N-r-ZvDLQdbPHaIU05GCZPxlFo5nSelV-wAxo2UhpVuikuepdI8YX0638h-LpH" alt="Add Security Groups to your EC2 Instance"/></figure>



<p>You probably have a Security Group in your list called launch-wizard-1 or something similar.&nbsp; <strong>Regardless of the name,&nbsp; click on it.</strong></p>


<div class="kb-row-layout-wrap kb-row-layout-id1788_d8beb8-19 alignnone wp-block-kadence-rowlayout"><div class="kt-row-column-wrap kt-has-1-columns kt-row-layout-equal kt-tab-layout-inherit kt-mobile-layout-row kt-row-valign-top">

<div class="wp-block-kadence-column kadence-column1788_b9d601-ca kb-section-dir-vertical inner-column-1"><div class="kt-inside-inner-col">
<div class="wp-block-kadence-column kadence-column1788_1acb87-25 inner-column-1"><div class="kt-inside-inner-col">
<span class="kt-adv-heading1788_b56a79-50 our-pick-arrow wp-block-kadence-advancedheading" data-kb-block="kb-adv-heading1788_b56a79-50"><mark class="kt-highlight">Note</mark></span>
</div></div>



<div class="wp-block-kadence-column kadence-column1788_789c92-7e inner-column-1"><div class="kt-inside-inner-col">
<p>A Security Group is where you assign rules for your server.&nbsp; <strong>Kind of a router/firewall</strong>.</p>



<p>Also, AWS will create a new Security Group for each server instance you create.&nbsp; For maintenance purposes, you should consider just re-using groups so you don&#8217;t have too many and they don&#8217;t become a maintenance issue in the future.</p>
</div></div>
</div></div>

</div></div>


<p></p>



<h3 class="wp-block-heading">Two Rule Types &#8211; Inbound and Outbound</h3>



<p>You&#8217;ll need to create inbound rules and outbound rules for your server.</p>



<h4 class="wp-block-heading">Inbound</h4>



<p>Traffic coming INTO your server.&nbsp; When a person is requesting a webpage on your server, that is INBOUND traffic.&nbsp; The request is coming IN.&nbsp; Your server currently has no Inbound rules by default, so nobody can access anything on your server yet.&nbsp; All traffic will be blocked.&nbsp; We&#8217;ll fix that in a moment.</p>



<h4 class="wp-block-heading">Outbound</h4>



<p>Traffic originating on your server but sending OUT a request to another server for some reason.</p>



<p>We&#8217;re going to allow all outbound ports.&nbsp; Your AWS server should come like this as the default.</p>



<h3 class="wp-block-heading"><strong>Incoming Rules to Set Up</strong></h3>



<p>If you have a <em>Linux-based Server</em>, add the following Inbound Rules.&nbsp; Click on the &#8220;Edit inbound rules&#8221; button to add them.</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/9ykj59_GJYpqLufeUWdxFzrG9v5GpoTr1QSow8SUMN6lBAFC5SoNFyZGxaRWSDth7wSPIJz6YlLxfo4oP9xDrDsKkX3dCxLhg82Oujn9bifBrTbn0IZGHWvOC_y7ctrVbqq0gOoRuDW5jTmytYT8ZxfzlVfmx0gmdYKoed3whxvq_FT1_b41fz4F" alt="Add Incoming Security Groups to your EC2 Linux Instance"/></figure>



<p>If you have a <em>Windows-based Server</em>, add the following Inbound Rules.&nbsp; Click on the &#8220;Edit inbound rules&#8221; button to add them.</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/T8bWsn8kFNHzolS7E3RFgvcFH0Q6bmBTK476q0raZd7_WTbdYR0qRB-dkzr_tyj0KHCke43H9UFV-X_4ypGrfPJjJZUiyj6rdvsrxNGfsAzU7banvcxCTwgqNf785I9_gj6012EVwrrhkqAnNvzoT1bm8JESi2HeYh-zFMdobmKt_QI6pZZqukOe" alt="Add Incoming Security Groups to your EC2 Windows Instance"/></figure>



<p>If you want to include FTP access on your Windows-based server, add it in as well.</p>



<h3 class="wp-block-heading"><strong>Outbound Rules to Setup</strong></h3>



<p>The below rules are standard for both <em>Linux-based</em> and <em>Windows-based</em> Servers.&nbsp; This should already be present, but add it if it&#8217;s missing, click on the &#8220;Edit outbound rules&#8221; button to add this one rule.</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh3.googleusercontent.com/xrye_Cmm-VEcH22QS1iEejszbLoEJCjldbom-7SJSsTPTfjwh6tkYZY5Zj5qLlgn60ZXoDd__KMVKqCiId8r-5Yo_pqd8UAhfwDquhI0XrU_lZcVR-B9whAm11Sz93FoMXv5e6BHwM4A6mQ8hMW3Uas3gbGKS5cYxofer_g_Gz4x4HsSlC2OSW9A" alt="Add Outbound Security Groups to your EC2 Instance"/></figure>



<p>Congrats!&nbsp; People should now be able to access your server!</p>



<h2 class="wp-block-heading">Step 5: Accessing Your Server</h2>



<p>You are now free to add files, install your personal software, and configure your server however you want.  But how do you do that?  It depends on the operating system you chose when setting up your instance.</p>



<p>From your EC2 Instance screen (found in the left navigation), click on your Instance details, and find the value for &#8220;Public IPv4 DNS&#8221;.&nbsp; It should look something like &#8220;<strong>ec1-23-456-789-555.compute-1.amazonaws.com</strong>&#8220;.&nbsp; That is your official server name to use in most situations.</p>



<h3 class="wp-block-heading"><strong>Windows-Based Server</strong></h3>



<p>You&#8217;ll probably want to set up a Remote Desktop Connection.&nbsp; For that:</p>



<ol class="wp-block-list">
<li>Go into your Instance details</li>



<li>Click on the &#8220;Connect&#8221; button at the top of the page</li>



<li>Click on the RDP client tab</li>
</ol>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="997" height="1024" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSConnectToInstanceFinal-997x1024.png" alt="" class="wp-image-1861" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSConnectToInstanceFinal-997x1024.png 997w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSConnectToInstanceFinal-292x300.png 292w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSConnectToInstanceFinal-768x789.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSConnectToInstanceFinal-1495x1536.png 1495w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSConnectToInstanceFinal-1993x2048.png 1993w" sizes="auto, (max-width: 997px) 100vw, 997px" /></figure>



<ol class="wp-block-list">
<li>Download the remote desktop file.&nbsp; You&#8217;ll want to take note of your &#8220;username&#8221;, and you need to generate your password value.&nbsp; For this, you need to enter your Key Pair and your password will be given to you.</li>
</ol>



<p>You should be able to now click on your remote desktop file and use your credentials to access your new server!</p>



<h3 class="wp-block-heading"><strong>Linux-Based Server</strong></h3>



<p>Your PEM file is fine for OpenSSH access, but for PuTTY use, you’ll need a PPK file.&nbsp; We can convert the PEM to a PPK file.&nbsp; Luckily the process is simple and has been <a href="https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-convert-a-PEM-file-to-PPK" target="_blank" rel="noreferrer noopener">documented here.</a></p>



<h2 class="wp-block-heading">Step 6: Smart Items To-Do</h2>



<h3 class="wp-block-heading"><strong>Create an AMI</strong></h3>



<p>This isn&#8217;t required but certainly is good to have in case something happens to your server.  It&#8217;s basically an image of the server that you can use as a restore point or for replication purposes if you want all the servers to be congruent.</p>



<figure class="wp-block-image size-large is-resized is-style-default"><img loading="lazy" decoding="async" width="818" height="1024" src="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSAMINavigation-818x1024.png" alt="" class="wp-image-1859" style="width:409px;height:512px" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/AWSAMINavigation-818x1024.png 818w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSAMINavigation-240x300.png 240w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSAMINavigation-768x961.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSAMINavigation-1228x1536.png 1228w, https://blog.gravyware.com/wp-content/uploads/2022/09/AWSAMINavigation-1637x2048.png 1637w" sizes="auto, (max-width: 818px) 100vw, 818px" /></figure>



<p>The full instructions will be in a later blog post, but if you click on the &#8220;EC2 Image Builder&#8221; button at the top of the page, it will get you started.</p>



<p>Having an image of your server allows you can restore another server at exactly this point and configuration next time.&nbsp; Boom!</p>



<h3 class="wp-block-heading">Setup a Monitoring Service</h3>



<p><a href="https://monitor.gravyware.com" target="_blank" rel="noreferrer noopener">Go here to set up a free monitoring service</a>.  You need something to tell you if your server crashes and becomes unreachable.  Trust us&#8230; you want this.  If you create any scheduled jobs on your new server, you&#8217;ll want to <a href="https://blog.gravyware.com/tracking-and-monitoring-cron-jobs" data-type="post" data-id="910" target="_blank" rel="noreferrer noopener">monitor all your Cron jobs</a> to make sure they are functioning as expected.</p>



<p>Once your website is up and running, be sure to add some <a href="https://blog.gravyware.com/best-social-proof-tools-to-improve-your-business" target="_blank" rel="noreferrer noopener">free social proof</a> to it so you can grow your audience!</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Congratulations!  You now have a fully functioning web server hosted in the cloud at AWS.</p>



<p>Please let me know if you have any questions at all and I will do everything I can to help you out.</p>



<p></p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Creating A Sitemap: How to Greatly Increase the Traffic your Website Receives</title>
		<link>https://blog.gravyware.com/how-to-triple-the-traffic-your-website-receives-from-google-a-step-by-step-guide-on-creating-and-submitting-a-sitemap</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Thu, 02 Jun 2022 15:55:00 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Marketing]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[growth hacking]]></category>
		<category><![CDATA[marketing]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=929</guid>

					<description><![CDATA[A proper sitemap can greatly increase your traffic from the search engines.  We explain how easy it is creating a sitemap, and submit it to Google and Bing.]]></description>
										<content:encoded><![CDATA[
<p>If you&#8217;re a website owner, creating a sitemap should be one of the first things you do.  You know that ranking high in Google search results is essential to attracting new visitors. Did you know, though, that using a sitemap can help triple your traffic from Google? In this blog post, we&#8217;ll explain what a sitemap is and how to create and submit one to improve your website&#8217;s SEO. So whether you&#8217;re just getting started with SEO or want to take your efforts to the next level, read on for tips on using a sitemap to increase your visibility in Google search results!</p>



<h2 class="wp-block-heading">A Little History</h2>



<p>In the late 1990s, the major search engines would spend all their time aimlessly spidering the web and filling up their databases with what they found. &nbsp;Search results wouldn&#8217;t necessarily &nbsp;contain the the best sites, just the ones that they currently had in the system. &nbsp; They eventually began allowing you to submit your URL to them, which quickly created a queue of up to six months long to get your site indexed. &nbsp;It was incredibly slow and inadequate for the rapid growth of the internet.</p>



<p>Now, the major search engines want you to do do a bit more work to categorize and actually tell them what pages are important. &nbsp;they are requiring website owners to create an index of all the relevant pages within their site, and submit that to them. &nbsp;This is where XML sitemaps came in &#8211; they provide a way for website owners to submit a list of their pages to the search engine, telling them which ones are most important so that they can be indexed more thoroughly.</p>



<h2 class="wp-block-heading">What is a sitemap?</h2>



<p>A sitemap is an XML file that lists all the URLs for a website. It also includes information about each URL, such as when it was last updated and how important it is relative to other URLs on the site. &nbsp;This information helps search engines index your website more thoroughly and accurately. &nbsp;It might look like this:</p>



<figure class="wp-block-image"><img decoding="async" src="https://gravywareblog-media.s3.amazonaws.com/socialsitemap.png" alt="creating a sitemap"/></figure>



<h2 class="wp-block-heading">What are the benefits of Creating a sitemap for your website?</h2>



<p>Well, it&#8217;s important to note that Google and Bing probably won&#8217;t include your site into their database unless you start creating a sitemap. &nbsp;There are a few exceptions to this but for the most part, this rule is the law.</p>



<p>It is also an important way to inform search engines of all the pages on your site, so they can be included in search results. Search engines use a variety of factors to determine how important each page is, but they don&#8217;t index every page on your website automatically. Creating a sitemap helps ensure that more pages from your site will be included in search results.</p>



<p>So let&#8217;s create a sitemap!</p>



<h2 class="wp-block-heading">How can you start creating a sitemap?</h2>



<p>There are many ways to begin creating a sitemap. &nbsp;You could hand code them, use an online generator, or look for plugins that will help you automatically generate one in your CMS of choice.</p>



<h3 class="wp-block-heading"><strong>Check to see if a sitemap already exists</strong></h3>



<p>If you are using a CMS like WordPress or Joomla, they might have already create a sitemap for you.</p>



<p>Try to access https://www.yourdomain.com/sitemap.xml or https://www.yourdomain.com/sitemap</p>



<p>If you see an XML page already created, that&#8217;s awesome! &nbsp;The hard work is already done. &nbsp;If not, a plugin probably exists that will do this for you. &nbsp;Search for one within your CMS to get this created.</p>



<h3 class="wp-block-heading">Creating a Sitemap Manually</h3>



<p>If you&#8217;re not too familiar with XML, hand coding a sitemap can be tricky. &nbsp;There are online tools that will create one for you such as:</p>



<p><a href="https://www.xml-sitemaps.com" target="_blank" rel="noreferrer noopener">https://www.xml-sitemaps.com</a></p>



<p><a href="https://www.sureoak.com/seo-tools/google-xml-sitemap-generator" target="_blank" rel="noreferrer noopener">https://www.sureoak.com/seo-tools/google-xml-sitemap-generator</a></p>



<p>All you need to do is enter in the URL of your website and it will generate an XML file for you.</p>



<h2 class="wp-block-heading">Having your sitemap update auto-magically</h2>



<p>Now that finished creating your sitemap, it&#8217;s important to keep it updated. &nbsp;If you make changes to your website and don&#8217;t update your sitemap, the search engine might not be aware of the new pages.</p>



<p>This one requires a bit of programming knowledge, but is great at getting new site updates into Google and Bing within days. &nbsp;If you have a blog, or have consistent updates to your site, update your sitemap to let Google know about them. &nbsp;It is best practice to update your sitemap at least once a week.</p>



<p>For this blog, we have each blog post added immediately to our sitemap with name, url, and updated date. &nbsp;This way, as the search engines hit our sitemap daily, they see that the new blog posts and immediately add them to their database. &nbsp;We have seen a tremendous spike in traffic since implementing this method.</p>



<p>Facebook does this with your profile pages. &nbsp;The search engines know about them quickly, which is why your Facebook profile is a link directly from within Google.</p>



<h2 class="wp-block-heading">Updating your website with your sitemap</h2>



<p>Ok, so you have a sitemap created.</p>



<ol class="wp-block-list">
<li>Make sure it&#8217;s named &#8220;sitemap.xml&#8221; (Search engines actually search for it with this name)</li>



<li>Put it in the root folder of your website.</li>



<li>Verify that you can access it at &#8211; https://www.yourdomain.com/sitemap.xml</li>
</ol>



<h2 class="wp-block-heading">Submitting your sitemap to Google and Bing</h2>



<p>Now that you finished creating a sitemap and placed it on your website, it&#8217;s time to update Google and Bing. &nbsp;To do this, log into their respective webmaster tools:</p>



<p>Google Webmaster Tools: <a href="https://search.google.com/u/1/search-console" target="_blank" rel="noreferrer noopener">https://search.google.com/u/1/search-console</a></p>



<p>Bing Webmaster Tools: <a href="https://www.bing.com/webmasters/home" target="_blank" rel="noreferrer noopener">https://www.bing.com/webmasters/home</a></p>



<p>Once logged in, find the Sitemaps area (currently on the left navigation).</p>



<h3 class="wp-block-heading">Google &#8211;&nbsp;</h3>



<figure class="wp-block-image"><img decoding="async" src="https://gravywareblog-media.s3.amazonaws.com/googlesitemapsscreenshot.png" alt="creating a sitemap in Google"/></figure>



<h3 class="wp-block-heading">Bing &#8211;&nbsp;</h3>



<figure class="wp-block-image"><img decoding="async" src="https://gravywareblog-media.s3.amazonaws.com/bingsitemapsscreenshot.png" alt="Creating a sitemap in Bing"/></figure>



<p>Within this area, submit the sitemap URL. &nbsp;You should be able to quickly see if the format is acceptable as Google and Bing hit your sitemap.</p>



<p>While you&#8217;re in there, be sure to check out all the other tools you can use to utilize the search engines to their fullest.</p>



<h2 class="wp-block-heading">Congratulations!</h2>



<p>You did it! You have successfully created a sitemap and submitted it to Google and Bing. Now it&#8217;s time to wait for them to index your website. In the meantime, continue optimizing your website content and adding new pages/posts. The more quality content you have, the better chance you&#8217;ll have of ranking higher in search engine results pages (SERPs).</p>



<p>Don&#8217;t forget your can use our free <a href="https://seorank.gravyware.com/" target="_blank" rel="noreferrer noopener">SEO Ranking tool</a> to make sure your pages are optimized for Google and Bing.</p>



<p>If you have any questions or need help, please don&#8217;t hesitate to contact us. We&#8217;re more than happy to assist!</p>



<h2 class="wp-block-heading">You Might Also Like</h2>



<ul class="wp-block-list">
<li><a href="https://blog.gravyware.com/best-social-proof-tools-to-improve-your-business" data-type="URL" data-id="https://blog.gravyware.com/best-social-proof-tools-to-improve-your-business">The 21 Best Social Proof Tools To Improve Your Business</a></li>
</ul>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How To Use a Server Status Page to Reduce Costs and Improve Customer Relationships</title>
		<link>https://blog.gravyware.com/how-to-use-a-status-page-to-reduce-costs-and-improve-customer-relationships</link>
		
		<dc:creator><![CDATA[David Garthe]]></dc:creator>
		<pubDate>Mon, 23 May 2022 15:44:00 +0000</pubDate>
				<category><![CDATA[Server Monitoring]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">https://blog.gravyware.com/?p=914</guid>

					<description><![CDATA[A server status page is a critical part of your business continuity plan. By providing information to customers about outages and other disruptions, you can minimize the impact on your business.]]></description>
										<content:encoded><![CDATA[
<p><br>A status page is a critical part of your business continuity plan. By providing information to customers about outages and other disruptions, you can minimize the impact on your business. A good status page will also help you proactively answer customer questions before they have a chance to call or tweet.</p>



<h2 class="wp-block-heading">Why you absolutely need a Server status page</h2>



<p>Most importantly, a status page can help prevent unhappy customers becoming ex-customers. &nbsp; It keeps a level of open-communication that is critical to great customer service.</p>



<p>If you&#8217;re not sure if you need a status page, ask yourself these questions:</p>



<ul class="wp-block-list">
<li>Do we experience outages or downtime that I would like to communicate to our customers?</li>



<li>Are our customers frequently asking me about our service status?</li>



<li>Do I need to proactively answer customer questions about our service reliability?</li>
</ul>



<p>If you answered yes to any of these, then you need a status page.</p>



<p>You might think&#8230; I don&#8217;t want someone to know when my site goes down! &nbsp;That will publicize that I&#8217;m having troubles. &nbsp;But the opposite has actually proven true. &nbsp;Being forthcoming with this information actually improves customer relations. &nbsp;Your customers might rely on your application to do business themselves, and helping them understand the situation will go a long way with setting expectations with their own clients.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="822" height="584" src="https://blog.gravyware.com/wp-content/uploads/2022/09/image.png" alt="" class="wp-image-1705" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/image.png 822w, https://blog.gravyware.com/wp-content/uploads/2022/09/image-300x213.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/image-768x546.png 768w" sizes="auto, (max-width: 822px) 100vw, 822px" /></figure>
</div>


<p>Creating and maintaining a status page doesn&#8217;t have to be difficult. There are many services available that can help you get started. In addition, there are many resources online that can help you create an effective page. <a href="https://monitor.gravyware.com" target="_blank" rel="noreferrer noopener">Gravyware&#8217;s Monitoring free tool</a> provides you an excellent one to use.</p>



<p>If you&#8217;re not sure where to start, sign up for a free account and you can get set up quickly and easily.</p>



<h2 class="wp-block-heading">Successful uses of a Server Status page</h2>



<p>There are numerous businesses that have successfully used a status page to improve their customer service. Some notable examples include:</p>



<p></p>



<div class="wp-block-media-text is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-1024x1024.png" alt="twitter logo" class="wp-image-1676 size-full" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-1024x1024.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-300x300.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-150x150.png 150w, https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-768x768.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-1536x1536.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/twitterLogoRound-2048x2048.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure><div class="wp-block-media-text__content">
<h3 class="wp-block-heading"><strong>Twitter</strong></h3>



<p> In 2011, Twitter was suffering from routine outages that impacted users around the globe. They were able to effectively communicate with their customers through implementing a status page which helped avoid any additional PR disasters.</p>



<p><a href="https://api.twitterstat.us" target="_blank" rel="noreferrer noopener">Twitter&#8217;s Status Page</a></p>
</div></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<div class="wp-block-media-text has-media-on-the-right is-stacked-on-mobile"><div class="wp-block-media-text__content">
<h3 class="wp-block-heading"><strong>Netflix</strong></h3>



<p>Netflix has been known for its poor customer service in the past. However, they turned things around when they implemented a comprehensive status page strategy in 2014. The page was updated regularly with information about outages and other disruptions in service.</p>



<p><a href="https://help.netflix.com/en/is-netflix-down" target="_blank" rel="noreferrer noopener">Netflix Status Page</a></p>
</div><figure class="wp-block-media-text__media"><img loading="lazy" decoding="async" width="684" height="410" src="https://blog.gravyware.com/wp-content/uploads/2022/09/netflixLogo.png" alt="netflix logo" class="wp-image-1678 size-full" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/netflixLogo.png 684w, https://blog.gravyware.com/wp-content/uploads/2022/09/netflixLogo-300x180.png 300w" sizes="auto, (max-width: 684px) 100vw, 684px" /></figure></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<div class="wp-block-media-text is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img loading="lazy" decoding="async" width="1024" height="683" src="https://blog.gravyware.com/wp-content/uploads/2022/09/dropboxLogo-1024x683.png" alt="dropbox logo" class="wp-image-1679 size-full" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/dropboxLogo-1024x683.png 1024w, https://blog.gravyware.com/wp-content/uploads/2022/09/dropboxLogo-300x200.png 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/dropboxLogo-768x512.png 768w, https://blog.gravyware.com/wp-content/uploads/2022/09/dropboxLogo-1536x1024.png 1536w, https://blog.gravyware.com/wp-content/uploads/2022/09/dropboxLogo-2048x1365.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure><div class="wp-block-media-text__content">
<h3 class="wp-block-heading"><strong>Dropbox</strong></h3>



<p>Dropbox had an outage in 2013 that affected millions of users worldwide. The stress of the outage was equal to the customer relations nightmare.  A simple status page was implemented that would give updates to users and proactively communicated with their users while the outage was corrected.</p>



<p><a href="https://status.dropbox.com" target="_blank" rel="noreferrer noopener">Dropbox Status Page</a></p>
</div></div>



<p></p>



<h2 class="wp-block-heading">A Server Status page shows transparency</h2>



<p>Having a status page is essential for maintaining your company&#8217;s reputation. Customers value transparency and will appreciate knowing what is happening with your service. A well-maintained status page can even help prevent bad press in the event of an outage.</p>



<div class="wp-block-kadence-image kb-image914_8bfe6f-f4 is-style-default"><figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" src="https://blog.gravyware.com/wp-content/uploads/2022/09/transparency-1.jpg" alt="transparency image" class="kb-img wp-image-1699" width="705" height="353" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/transparency-1.jpg 940w, https://blog.gravyware.com/wp-content/uploads/2022/09/transparency-1-300x150.jpg 300w, https://blog.gravyware.com/wp-content/uploads/2022/09/transparency-1-768x384.jpg 768w" sizes="auto, (max-width: 705px) 100vw, 705px" /></figure></div>



<p>A well-maintained status page is also <em>pro-active.</em> &nbsp;It shows your customers that you <em>want</em> them to know about issues so that they have time to prepare for their own customer communications.</p>



<h2 class="wp-block-heading">A Server Status page can save you money</h2>



<p>It will cost you a lot of money to react to customer calls and unplanned events. &nbsp; A status page can help you prevent these types of events from happening in the first place. Having a page that is always up-to-date with your latest information will let your customers know that you&#8217;re reliable and proactive.</p>


<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img loading="lazy" decoding="async" width="612" height="459" src="https://blog.gravyware.com/wp-content/uploads/2022/09/growthChart.jpg" alt="" class="wp-image-1684" style="width:459px;height:344px" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/growthChart.jpg 612w, https://blog.gravyware.com/wp-content/uploads/2022/09/growthChart-300x225.jpg 300w" sizes="auto, (max-width: 612px) 100vw, 612px" /></figure>
</div>


<h2 class="wp-block-heading">A Server status page can drive more business</h2>



<p>Of course, a status page can also show potential customers your site reliability. &nbsp; It should show uptime &nbsp;and downtime statistics, and information about your service providers.</p>



<h2 class="wp-block-heading">It gives you some legitimacy</h2>



<p>Savvy customers have become use to seeing a link to a status page for the best companies. &nbsp;They realize the risks of using an outside company for a service and may actually prefer to use a business that is forthcoming with server status information.</p>



<h2 class="wp-block-heading">What not to include on your Server Status page</h2>


<div class="wp-block-image">
<figure class="alignleft size-full is-resized"><img loading="lazy" decoding="async" width="640" height="626" src="https://blog.gravyware.com/wp-content/uploads/2022/09/dontDoThis.png" alt="" class="wp-image-1687" style="width:320px;height:313px" srcset="https://blog.gravyware.com/wp-content/uploads/2022/09/dontDoThis.png 640w, https://blog.gravyware.com/wp-content/uploads/2022/09/dontDoThis-300x293.png 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
</div>


<p>There are a few things you should avoid including on your status page. Personal information should not be published. You also don&#8217;t want to share any confidential company information that is not already available to the public.</p>



<p>Many companies do not want to include a &#8220;contact us&#8221; option on their status page. &nbsp;The reasoning is that you want users to reference the status page as the communication method instead of reverting to email or another means.</p>



<p>Finally, do not include internal system&#8217;s status on an external status page. &nbsp;Outside customers do not need to know that your internal chat program is having issues. &nbsp;This should be broadcast on a separate &#8220;internal only&#8221; status page (Gravyware has a password-protection option for you to keep a status page private). &nbsp;The exception to this is if an internal system failure is impacting an external system.</p>



<h2 class="wp-block-heading">How to use your Server status page to improve customer service</h2>



<figure class="wp-block-image"><img decoding="async" src="https://gravywareblog-media.s3.amazonaws.com/happycustomerlight-1.png" alt="server status page makes happy users!"/></figure>



<p>Once your status page is set up, it&#8217;s important to use it effectively. The first step is ensuring that your contact information is correct and easily found.  You should also make sure that all of your social media links are included on the page.</p>



<p>In addition, you&#8217;ll want to ensure that outage information is updated as soon as possible. This will help customers avoid any confusion or misinformation.</p>



<p>Finally, be sure to keep an archive of past outages and incidents for future reference. Doing so can help you improve your service going forward.</p>



<h2 class="wp-block-heading">Setting up a Server Status page for your business</h2>



<p>As mentioned previously, there are multiple companies that provide status page options for you. &nbsp;Some status pages are manually updated and some are automated. &nbsp;<a href="https://monitor.gravyware.com" target="_blank" rel="noreferrer noopener">Gravyware Monitoring&#8217;s free option</a> is super simple to setup, and connects with the site monitoring service offered (so it&#8217;s automated). &nbsp;We particularly like the automated version as it adds to the transparency impact mentioned above.</p>



<p>Whichever option your decide upon, make sure you choose a good URL for the page itself (typically you choose through the status page admin area), and make it search engine accessible.</p>



<p>You will also want to link to the status page from your main site. &nbsp;Think of it as another page making up your main application. &nbsp;<a href="https://monitor.gravyware.com/s/gravyware/" target="_blank" rel="noreferrer noopener">Gravyware&#8217;s status page is located here</a>. &nbsp;We include it in the footer throughout all of our sites.</p>



<p>Finally, customize it as much as allowed so that it truly looks like your creation.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>A status page is an important part of any company&#8217;s communication strategy. It can help you with communication during outages, ultimately save you money, and improve your customer service all at the same time. &nbsp;If you have any questions or comments regarding this blog post <a href="https://blog.gravyware.com/contact" target="_blank" rel="noreferrer noopener">please reach out</a> to the Gravyware team.</p>



<p>Good luck!</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: blog.gravyware.com @ 2026-05-06 12:56:26 by W3 Total Cache
-->