<?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>advanced custom fields Archives - Developry Plugins</title>
	<atom:link href="https://developryplugins.com/tag/advanced-custom-fields/feed/" rel="self" type="application/rss+xml" />
	<link>https://developryplugins.com/tag/advanced-custom-fields/</link>
	<description></description>
	<lastBuildDate>Mon, 24 Nov 2025 11:18:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://developryplugins.com/wp-content/uploads/2026/06/cropped-favicon-alt-32x32.webp</url>
	<title>advanced custom fields Archives - Developry Plugins</title>
	<link>https://developryplugins.com/tag/advanced-custom-fields/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>ACF Tutorial: Building Custom Post Types with Advanced Custom Fields</title>
		<link>https://developryplugins.com/acf-tutorial-building-custom-post-types-with-advanced-custom-fields/</link>
		
		<dc:creator><![CDATA[Krasen Slavov]]></dc:creator>
		<pubDate>Mon, 10 Nov 2025 09:00:00 +0000</pubDate>
				<category><![CDATA[Advanced Custom Fields (ACF) Tutorials]]></category>
		<category><![CDATA[acf]]></category>
		<category><![CDATA[acf tutorial]]></category>
		<category><![CDATA[advanced custom fields]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[custom post types]]></category>
		<guid isPermaLink="false">https://developryplugins.com/?p=111</guid>

					<description><![CDATA[<p>Advanced Custom Fields transforms WordPress custom post types from basic content containers into feature-rich data structures through intuitive field group interfaces. From text fields and image uploads to relationship fields...</p>
<p>The post <a href="https://developryplugins.com/acf-tutorial-building-custom-post-types-with-advanced-custom-fields/">ACF Tutorial: Building Custom Post Types with Advanced Custom Fields</a> appeared first on <a href="https://developryplugins.com">Developry Plugins</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><!-- @format --></p>
<p>Advanced Custom Fields transforms WordPress custom post types from basic content containers into feature-rich data structures through intuitive field group interfaces. From text fields and image uploads to relationship fields and repeaters, ACF enables complex content management without custom database tables. This comprehensive tutorial teaches ACF installation, field group creation, custom post type registration, field display techniques, and query integration building professional WordPress applications with ACF.</p>
<h2 id="installing-advanced-custom-fields">Installing Advanced Custom Fields</h2>
<p><strong>Install ACF Plugin</strong>:</p>
<ol type="1">
<li>Plugins → Add New</li>
<li>Search “Advanced Custom Fields”</li>
<li>Install and activate ACF (free) or ACF PRO</li>
</ol>
<p><strong>ACF Free vs PRO</strong>:</p>
<p>Free includes:</p>
<ul>
<li>Basic field types</li>
<li>Field groups</li>
<li>Location rules</li>
</ul>
<p>PRO adds:</p>
<ul>
<li>Repeater fields</li>
<li>Flexible content</li>
<li>Gallery fields</li>
<li>Clone fields</li>
<li>Options pages</li>
</ul>
<h2 id="registering-custom-post-type">Registering Custom Post Type</h2>
<p><strong>Register Portfolio CPT</strong> (functions.php):</p>
<div class="sourceCode" id="cb1">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true"></a><span class="kw">function</span> mytheme_register_portfolio<span class="ot">()</span> {</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true"></a>    register_post_type<span class="ot">(</span><span class="st">&#39;portfolio&#39;</span><span class="ot">,</span> <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true"></a>        <span class="st">&#39;labels&#39;</span> =&gt; <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true"></a>            <span class="st">&#39;name&#39;</span>          =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;Portfolio&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true"></a>            <span class="st">&#39;singular_name&#39;</span> =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;Portfolio Item&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true"></a>            <span class="st">&#39;add_new&#39;</span>       =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;Add New&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true"></a>            <span class="st">&#39;add_new_item&#39;</span>  =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;Add New Portfolio Item&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true"></a>            <span class="st">&#39;edit_item&#39;</span>     =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;Edit Portfolio Item&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true"></a>            <span class="st">&#39;new_item&#39;</span>      =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;New Portfolio Item&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true"></a>            <span class="st">&#39;view_item&#39;</span>     =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;View Portfolio Item&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true"></a>            <span class="st">&#39;search_items&#39;</span>  =&gt; <span class="kw">__</span><span class="ot">(</span><span class="st">&#39;Search Portfolio&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme&#39;</span><span class="ot">),</span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true"></a>        <span class="ot">),</span></span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true"></a>        <span class="st">&#39;public&#39;</span>       =&gt; <span class="kw">true</span><span class="ot">,</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true"></a>        <span class="st">&#39;has_archive&#39;</span>  =&gt; <span class="kw">true</span><span class="ot">,</span></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true"></a>        <span class="st">&#39;rewrite&#39;</span>      =&gt; <span class="kw">array</span><span class="ot">(</span><span class="st">&#39;slug&#39;</span> =&gt; <span class="st">&#39;portfolio&#39;</span><span class="ot">),</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true"></a>        <span class="st">&#39;supports&#39;</span>     =&gt; <span class="kw">array</span><span class="ot">(</span><span class="st">&#39;title&#39;</span><span class="ot">,</span> <span class="st">&#39;editor&#39;</span><span class="ot">,</span> <span class="st">&#39;thumbnail&#39;</span><span class="ot">,</span> <span class="st">&#39;excerpt&#39;</span><span class="ot">),</span></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true"></a>        <span class="st">&#39;menu_icon&#39;</span>    =&gt; <span class="st">&#39;dashicons-portfolio&#39;</span><span class="ot">,</span></span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true"></a>        <span class="st">&#39;show_in_rest&#39;</span> =&gt; <span class="kw">true</span><span class="ot">,</span></span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true"></a>    <span class="ot">));</span></span>
<span id="cb1-20"><a href="#cb1-20" aria-hidden="true"></a>}</span>
<span id="cb1-21"><a href="#cb1-21" aria-hidden="true"></a>add_action<span class="ot">(</span><span class="st">&#39;init&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_register_portfolio&#39;</span><span class="ot">);</span></span></code></pre>
</div>
<h2 id="creating-field-groups">Creating Field Groups</h2>
<p><strong>Add Field Group via ACF UI</strong>:</p>
<ol type="1">
<li>Custom Fields → Add New</li>
<li>Title: “Portfolio Fields”</li>
<li>Add fields (see below)</li>
<li>Location Rules: Post Type = Portfolio</li>
<li>Publish</li>
</ol>
<p><strong>Field Configuration Example</strong>:</p>
<p><strong>Client Name</strong> (Text):</p>
<ul>
<li>Field Label: Client Name</li>
<li>Field Name: client_name</li>
<li>Field Type: Text</li>
<li>Required: Yes</li>
</ul>
<p><strong>Project URL</strong> (URL):</p>
<ul>
<li>Field Label: Project URL</li>
<li>Field Name: project_url</li>
<li>Field Type: URL</li>
</ul>
<p><strong>Project Date</strong> (Date Picker):</p>
<ul>
<li>Field Label: Project Date</li>
<li>Field Name: project_date</li>
<li>Field Type: Date Picker</li>
<li>Display Format: d/m/Y</li>
<li>Return Format: Y-m-d</li>
</ul>
<p><strong>Project Images</strong> (Gallery &#8211; PRO):</p>
<ul>
<li>Field Label: Project Images</li>
<li>Field Name: project_images</li>
<li>Field Type: Gallery</li>
<li>Min/Max: Min 1, Max 10</li>
</ul>
<p><strong>Technologies Used</strong> (Checkbox):</p>
<ul>
<li>Field Label: Technologies</li>
<li>Field Name: technologies</li>
<li>Field Type: Checkbox</li>
<li>Choices:
<ul>
<li>wordpress : WordPress</li>
<li>php : PHP</li>
<li>javascript : JavaScript</li>
<li>react : React</li>
</ul>
</li>
</ul>
<h2 id="common-field-types">Common Field Types</h2>
<p><strong>Text Field</strong>:</p>
<pre><code>Field Type: Text
Used for: Short text (names, titles)
Returns: String</code></pre>
<p><strong>Textarea</strong>:</p>
<pre><code>Field Type: Textarea
Used for: Long text (descriptions)
Returns: String</code></pre>
<p><strong>Number</strong>:</p>
<pre><code>Field Type: Number
Used for: Numeric values
Returns: Integer/Float</code></pre>
<p><strong>Email</strong>:</p>
<pre><code>Field Type: Email
Used for: Email addresses
Returns: String (email)</code></pre>
<p><strong>URL</strong>:</p>
<pre><code>Field Type: URL
Used for: Web addresses
Returns: String (URL)</code></pre>
<p><strong>Image</strong>:</p>
<pre><code>Field Type: Image
Return Format: Array/URL/ID
Returns: Image data</code></pre>
<p><strong>File</strong>:</p>
<pre><code>Field Type: File
Return Format: Array/URL/ID
Returns: File data</code></pre>
<p><strong>Select</strong>:</p>
<pre><code>Field Type: Select
Used for: Dropdown selection
Returns: Selected value(s)</code></pre>
<p><strong>Checkbox</strong>:</p>
<pre><code>Field Type: Checkbox
Used for: Multiple selections
Returns: Array of values</code></pre>
<p><strong>Radio Button</strong>:</p>
<pre><code>Field Type: Radio Button
Used for: Single selection
Returns: Selected value</code></pre>
<p><strong>True/False</strong>:</p>
<pre><code>Field Type: True/False
Used for: On/off toggle
Returns: Boolean (1/0)</code></pre>
<p><strong>Relationship</strong> (PRO):</p>
<pre><code>Field Type: Relationship
Used for: Link to other posts
Returns: Array of post objects</code></pre>
<p><strong>Repeater</strong> (PRO):</p>
<pre><code>Field Type: Repeater
Used for: Repeating field sets
Returns: Array of field groups</code></pre>
<h2 id="displaying-acf-fields-in-templates">Displaying ACF Fields in Templates</h2>
<p><strong>Single Portfolio Template</strong> (single-portfolio.php):</p>
<div class="sourceCode" id="cb15">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true"></a><span class="kw">&lt;?php</span> get_header<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true"></a></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true"></a>&lt;div <span class="kw">class</span>=<span class="st">&quot;portfolio-single&quot;</span>&gt;</span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php <span class="kw">while</span> <span class="ot">(</span>have_posts<span class="ot">())</span> <span class="ot">:</span> the_post<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true"></a></span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true"></a>        &lt;article id=<span class="st">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> &lt;<span class="ot">?</span>php post_class<span class="ot">();</span> <span class="kw">?&gt;</span>&gt;</span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true"></a>            &lt;<span class="fu">header</span> <span class="kw">class</span>=<span class="st">&quot;entry-header&quot;</span>&gt;</span>
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true"></a>                &lt;h1 <span class="kw">class</span>=<span class="st">&quot;entry-title&quot;</span>&gt;&lt;<span class="ot">?</span>php the_title<span class="ot">();</span> <span class="kw">?&gt;</span>&lt;/h1&gt;</span>
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true"></a></span>
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php</span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true"></a>                <span class="co">// Get ACF fields</span></span>
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true"></a>                <span class="kw">$client_name</span> = get_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">);</span></span>
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true"></a>                <span class="kw">$project_url</span> = get_field<span class="ot">(</span><span class="st">&#39;project_url&#39;</span><span class="ot">);</span></span>
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true"></a>                <span class="kw">$project_date</span> = get_field<span class="ot">(</span><span class="st">&#39;project_date&#39;</span><span class="ot">);</span></span>
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true"></a>                <span class="kw">$technologies</span> = get_field<span class="ot">(</span><span class="st">&#39;technologies&#39;</span><span class="ot">);</span></span>
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true"></a>                <span class="kw">?&gt;</span></span>
<span id="cb15-17"><a href="#cb15-17" aria-hidden="true"></a></span>
<span id="cb15-18"><a href="#cb15-18" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">if</span> <span class="ot">(</span><span class="kw">$client_name</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-19"><a href="#cb15-19" aria-hidden="true"></a>                    &lt;p <span class="kw">class</span>=<span class="st">&quot;client-name&quot;</span>&gt;</span>
<span id="cb15-20"><a href="#cb15-20" aria-hidden="true"></a>                        &lt;strong&gt;Client:&lt;/strong&gt; &lt;<span class="ot">?</span>php <span class="kw">echo</span> esc_html<span class="ot">(</span><span class="kw">$client_name</span><span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb15-21"><a href="#cb15-21" aria-hidden="true"></a>                    &lt;/p&gt;</span>
<span id="cb15-22"><a href="#cb15-22" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-23"><a href="#cb15-23" aria-hidden="true"></a></span>
<span id="cb15-24"><a href="#cb15-24" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">if</span> <span class="ot">(</span><span class="kw">$project_date</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-25"><a href="#cb15-25" aria-hidden="true"></a>                    &lt;p <span class="kw">class</span>=<span class="st">&quot;project-date&quot;</span>&gt;</span>
<span id="cb15-26"><a href="#cb15-26" aria-hidden="true"></a>                        &lt;strong&gt;<span class="fu">Date</span>:&lt;/strong&gt; &lt;<span class="ot">?</span>php <span class="kw">echo</span> esc_html<span class="ot">(</span><span class="fu">date</span><span class="ot">(</span><span class="st">&#39;F Y&#39;</span><span class="ot">,</span> <span class="fu">strtotime</span><span class="ot">(</span><span class="kw">$project_date</span><span class="ot">)));</span> <span class="kw">?&gt;</span></span>
<span id="cb15-27"><a href="#cb15-27" aria-hidden="true"></a>                    &lt;/p&gt;</span>
<span id="cb15-28"><a href="#cb15-28" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-29"><a href="#cb15-29" aria-hidden="true"></a></span>
<span id="cb15-30"><a href="#cb15-30" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">if</span> <span class="ot">(</span><span class="kw">$project_url</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-31"><a href="#cb15-31" aria-hidden="true"></a>                    &lt;p <span class="kw">class</span>=<span class="st">&quot;project-url&quot;</span>&gt;</span>
<span id="cb15-32"><a href="#cb15-32" aria-hidden="true"></a>                        &lt;a href=<span class="st">&quot;&lt;?php echo esc_url(</span><span class="kw">$project_url</span><span class="st">); ?&gt;&quot;</span> target=<span class="st">&quot;_blank&quot;</span>&gt;</span>
<span id="cb15-33"><a href="#cb15-33" aria-hidden="true"></a>                            View Live Project</span>
<span id="cb15-34"><a href="#cb15-34" aria-hidden="true"></a>                        &lt;/a&gt;</span>
<span id="cb15-35"><a href="#cb15-35" aria-hidden="true"></a>                    &lt;/p&gt;</span>
<span id="cb15-36"><a href="#cb15-36" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-37"><a href="#cb15-37" aria-hidden="true"></a></span>
<span id="cb15-38"><a href="#cb15-38" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">if</span> <span class="ot">(</span><span class="kw">$technologies</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-39"><a href="#cb15-39" aria-hidden="true"></a>                    &lt;div <span class="kw">class</span>=<span class="st">&quot;technologies&quot;</span>&gt;</span>
<span id="cb15-40"><a href="#cb15-40" aria-hidden="true"></a>                        &lt;strong&gt;Technologies:&lt;/strong&gt;</span>
<span id="cb15-41"><a href="#cb15-41" aria-hidden="true"></a>                        &lt;ul&gt;</span>
<span id="cb15-42"><a href="#cb15-42" aria-hidden="true"></a>                            &lt;<span class="ot">?</span>php <span class="kw">foreach</span> <span class="ot">(</span><span class="kw">$technologies</span> <span class="kw">as</span> <span class="kw">$tech</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-43"><a href="#cb15-43" aria-hidden="true"></a>                                &lt;li&gt;&lt;<span class="ot">?</span>php <span class="kw">echo</span> esc_html<span class="ot">(</span><span class="kw">$tech</span><span class="ot">);</span> <span class="kw">?&gt;</span>&lt;/li&gt;</span>
<span id="cb15-44"><a href="#cb15-44" aria-hidden="true"></a>                            &lt;<span class="ot">?</span>php <span class="kw">endfor</span>each<span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-45"><a href="#cb15-45" aria-hidden="true"></a>                        &lt;/ul&gt;</span>
<span id="cb15-46"><a href="#cb15-46" aria-hidden="true"></a>                    &lt;/div&gt;</span>
<span id="cb15-47"><a href="#cb15-47" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-48"><a href="#cb15-48" aria-hidden="true"></a>            &lt;/<span class="fu">header</span>&gt;</span>
<span id="cb15-49"><a href="#cb15-49" aria-hidden="true"></a></span>
<span id="cb15-50"><a href="#cb15-50" aria-hidden="true"></a>            &lt;div <span class="kw">class</span>=<span class="st">&quot;entry-content&quot;</span>&gt;</span>
<span id="cb15-51"><a href="#cb15-51" aria-hidden="true"></a>                &lt;<span class="ot">?</span>php the_content<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb15-52"><a href="#cb15-52" aria-hidden="true"></a>            &lt;/div&gt;</span>
<span id="cb15-53"><a href="#cb15-53" aria-hidden="true"></a></span>
<span id="cb15-54"><a href="#cb15-54" aria-hidden="true"></a>            &lt;<span class="ot">?</span>php</span>
<span id="cb15-55"><a href="#cb15-55" aria-hidden="true"></a>            <span class="co">// Display gallery (ACF PRO)</span></span>
<span id="cb15-56"><a href="#cb15-56" aria-hidden="true"></a>            <span class="kw">$images</span> = get_field<span class="ot">(</span><span class="st">&#39;project_images&#39;</span><span class="ot">);</span></span>
<span id="cb15-57"><a href="#cb15-57" aria-hidden="true"></a>            <span class="kw">if</span> <span class="ot">(</span><span class="kw">$images</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-58"><a href="#cb15-58" aria-hidden="true"></a>                &lt;div <span class="kw">class</span>=<span class="st">&quot;project-gallery&quot;</span>&gt;</span>
<span id="cb15-59"><a href="#cb15-59" aria-hidden="true"></a>                    &lt;<span class="ot">?</span>php <span class="kw">foreach</span> <span class="ot">(</span><span class="kw">$images</span> <span class="kw">as</span> <span class="kw">$image</span><span class="ot">)</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb15-60"><a href="#cb15-60" aria-hidden="true"></a>                        &lt;div <span class="kw">class</span>=<span class="st">&quot;gallery-item&quot;</span>&gt;</span>
<span id="cb15-61"><a href="#cb15-61" aria-hidden="true"></a>                            &lt;a href=<span class="st">&quot;&lt;?php echo esc_url(</span><span class="kw">$image</span><span class="st">[&#39;url&#39;]); ?&gt;&quot;</span> data-lightbox=<span class="st">&quot;portfolio&quot;</span>&gt;</span>
<span id="cb15-62"><a href="#cb15-62" aria-hidden="true"></a>                                &lt;img src=<span class="st">&quot;&lt;?php echo esc_url(</span><span class="kw">$image</span><span class="st">[&#39;sizes&#39;][&#39;medium&#39;]); ?&gt;&quot;</span></span>
<span id="cb15-63"><a href="#cb15-63" aria-hidden="true"></a>                                     alt=<span class="st">&quot;&lt;?php echo esc_attr(</span><span class="kw">$image</span><span class="st">[&#39;alt&#39;]); ?&gt;&quot;</span> /&gt;</span>
<span id="cb15-64"><a href="#cb15-64" aria-hidden="true"></a>                            &lt;/a&gt;</span>
<span id="cb15-65"><a href="#cb15-65" aria-hidden="true"></a>                        &lt;/div&gt;</span>
<span id="cb15-66"><a href="#cb15-66" aria-hidden="true"></a>                    &lt;<span class="ot">?</span>php <span class="kw">endfor</span>each<span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-67"><a href="#cb15-67" aria-hidden="true"></a>                &lt;/div&gt;</span>
<span id="cb15-68"><a href="#cb15-68" aria-hidden="true"></a>            &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-69"><a href="#cb15-69" aria-hidden="true"></a>        &lt;/article&gt;</span>
<span id="cb15-70"><a href="#cb15-70" aria-hidden="true"></a></span>
<span id="cb15-71"><a href="#cb15-71" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php <span class="kw">endwhile</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb15-72"><a href="#cb15-72" aria-hidden="true"></a>&lt;/div&gt;</span>
<span id="cb15-73"><a href="#cb15-73" aria-hidden="true"></a></span>
<span id="cb15-74"><a href="#cb15-74" aria-hidden="true"></a>&lt;<span class="ot">?</span>php get_footer<span class="ot">();</span> <span class="kw">?&gt;</span></span></code></pre>
</div>
<h2 id="archive-template">Archive Template</h2>
<p><strong>Portfolio Archive</strong> (archive-portfolio.php):</p>
<div class="sourceCode" id="cb16">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true"></a><span class="kw">&lt;?php</span> get_header<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true"></a></span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true"></a>&lt;div <span class="kw">class</span>=<span class="st">&quot;portfolio-archive&quot;</span>&gt;</span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true"></a>    &lt;<span class="fu">header</span> <span class="kw">class</span>=<span class="st">&quot;page-header&quot;</span>&gt;</span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true"></a>        &lt;h1&gt;Portfolio&lt;/h1&gt;</span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true"></a>    &lt;/<span class="fu">header</span>&gt;</span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true"></a></span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php <span class="kw">if</span> <span class="ot">(</span>have_posts<span class="ot">())</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true"></a>        &lt;div <span class="kw">class</span>=<span class="st">&quot;portfolio-grid&quot;</span>&gt;</span>
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true"></a>            &lt;<span class="ot">?</span>php <span class="kw">while</span> <span class="ot">(</span>have_posts<span class="ot">())</span> <span class="ot">:</span> the_post<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true"></a></span>
<span id="cb16-12"><a href="#cb16-12" aria-hidden="true"></a>                &lt;article id=<span class="st">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> &lt;<span class="ot">?</span>php post_class<span class="ot">(</span><span class="st">&#39;portfolio-item&#39;</span><span class="ot">);</span> <span class="kw">?&gt;</span>&gt;</span>
<span id="cb16-13"><a href="#cb16-13" aria-hidden="true"></a>                    &lt;<span class="ot">?</span>php <span class="kw">if</span> <span class="ot">(</span>has_post_thumbnail<span class="ot">())</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb16-14"><a href="#cb16-14" aria-hidden="true"></a>                        &lt;div <span class="kw">class</span>=<span class="st">&quot;portfolio-thumbnail&quot;</span>&gt;</span>
<span id="cb16-15"><a href="#cb16-15" aria-hidden="true"></a>                            &lt;a href=<span class="st">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span>&gt;</span>
<span id="cb16-16"><a href="#cb16-16" aria-hidden="true"></a>                                &lt;<span class="ot">?</span>php the_post_thumbnail<span class="ot">(</span><span class="st">&#39;medium&#39;</span><span class="ot">);</span> <span class="kw">?&gt;</span></span>
<span id="cb16-17"><a href="#cb16-17" aria-hidden="true"></a>                            &lt;/a&gt;</span>
<span id="cb16-18"><a href="#cb16-18" aria-hidden="true"></a>                        &lt;/div&gt;</span>
<span id="cb16-19"><a href="#cb16-19" aria-hidden="true"></a>                    &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb16-20"><a href="#cb16-20" aria-hidden="true"></a></span>
<span id="cb16-21"><a href="#cb16-21" aria-hidden="true"></a>                    &lt;div <span class="kw">class</span>=<span class="st">&quot;portfolio-content&quot;</span>&gt;</span>
<span id="cb16-22"><a href="#cb16-22" aria-hidden="true"></a>                        &lt;h2 <span class="kw">class</span>=<span class="st">&quot;entry-title&quot;</span>&gt;</span>
<span id="cb16-23"><a href="#cb16-23" aria-hidden="true"></a>                            &lt;a href=<span class="st">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span>&gt;&lt;<span class="ot">?</span>php the_title<span class="ot">();</span> <span class="kw">?&gt;</span>&lt;/a&gt;</span>
<span id="cb16-24"><a href="#cb16-24" aria-hidden="true"></a>                        &lt;/h2&gt;</span>
<span id="cb16-25"><a href="#cb16-25" aria-hidden="true"></a></span>
<span id="cb16-26"><a href="#cb16-26" aria-hidden="true"></a>                        &lt;<span class="ot">?</span>php</span>
<span id="cb16-27"><a href="#cb16-27" aria-hidden="true"></a>                        <span class="kw">$client_name</span> = get_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">);</span></span>
<span id="cb16-28"><a href="#cb16-28" aria-hidden="true"></a>                        <span class="kw">if</span> <span class="ot">(</span><span class="kw">$client_name</span><span class="ot">)</span> <span class="ot">:</span></span>
<span id="cb16-29"><a href="#cb16-29" aria-hidden="true"></a>                            <span class="kw">?&gt;</span></span>
<span id="cb16-30"><a href="#cb16-30" aria-hidden="true"></a>                            &lt;p <span class="kw">class</span>=<span class="st">&quot;client&quot;</span>&gt;Client: &lt;<span class="ot">?</span>php <span class="kw">echo</span> esc_html<span class="ot">(</span><span class="kw">$client_name</span><span class="ot">);</span> <span class="kw">?&gt;</span>&lt;/p&gt;</span>
<span id="cb16-31"><a href="#cb16-31" aria-hidden="true"></a>                        &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb16-32"><a href="#cb16-32" aria-hidden="true"></a></span>
<span id="cb16-33"><a href="#cb16-33" aria-hidden="true"></a>                        &lt;div <span class="kw">class</span>=<span class="st">&quot;entry-excerpt&quot;</span>&gt;</span>
<span id="cb16-34"><a href="#cb16-34" aria-hidden="true"></a>                            &lt;<span class="ot">?</span>php the_excerpt<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb16-35"><a href="#cb16-35" aria-hidden="true"></a>                        &lt;/div&gt;</span>
<span id="cb16-36"><a href="#cb16-36" aria-hidden="true"></a></span>
<span id="cb16-37"><a href="#cb16-37" aria-hidden="true"></a>                        &lt;a href=<span class="st">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> <span class="kw">class</span>=<span class="st">&quot;read-more&quot;</span>&gt;</span>
<span id="cb16-38"><a href="#cb16-38" aria-hidden="true"></a>                            View Project</span>
<span id="cb16-39"><a href="#cb16-39" aria-hidden="true"></a>                        &lt;/a&gt;</span>
<span id="cb16-40"><a href="#cb16-40" aria-hidden="true"></a>                    &lt;/div&gt;</span>
<span id="cb16-41"><a href="#cb16-41" aria-hidden="true"></a>                &lt;/article&gt;</span>
<span id="cb16-42"><a href="#cb16-42" aria-hidden="true"></a></span>
<span id="cb16-43"><a href="#cb16-43" aria-hidden="true"></a>            &lt;<span class="ot">?</span>php <span class="kw">endwhile</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb16-44"><a href="#cb16-44" aria-hidden="true"></a>        &lt;/div&gt;</span>
<span id="cb16-45"><a href="#cb16-45" aria-hidden="true"></a></span>
<span id="cb16-46"><a href="#cb16-46" aria-hidden="true"></a>        &lt;<span class="ot">?</span>php the_posts_pagination<span class="ot">();</span> <span class="kw">?&gt;</span></span>
<span id="cb16-47"><a href="#cb16-47" aria-hidden="true"></a></span>
<span id="cb16-48"><a href="#cb16-48" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php <span class="kw">else</span> <span class="ot">:</span> <span class="kw">?&gt;</span></span>
<span id="cb16-49"><a href="#cb16-49" aria-hidden="true"></a>        &lt;p&gt;No portfolio items found.&lt;/p&gt;</span>
<span id="cb16-50"><a href="#cb16-50" aria-hidden="true"></a>    &lt;<span class="ot">?</span>php <span class="kw">endif</span><span class="ot">;</span> <span class="kw">?&gt;</span></span>
<span id="cb16-51"><a href="#cb16-51" aria-hidden="true"></a>&lt;/div&gt;</span>
<span id="cb16-52"><a href="#cb16-52" aria-hidden="true"></a></span>
<span id="cb16-53"><a href="#cb16-53" aria-hidden="true"></a>&lt;<span class="ot">?</span>php get_footer<span class="ot">();</span> <span class="kw">?&gt;</span></span></code></pre>
</div>
<h2 id="querying-posts-with-acf-meta">Querying Posts with ACF Meta</h2>
<p><strong>Query by ACF Field Value</strong>:</p>
<div class="sourceCode" id="cb17">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true"></a><span class="co">// Query portfolio items by client name</span></span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true"></a><span class="kw">$args</span> = <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true"></a>    <span class="st">&#39;post_type&#39;</span>  =&gt; <span class="st">&#39;portfolio&#39;</span><span class="ot">,</span></span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true"></a>    <span class="st">&#39;meta_key&#39;</span>   =&gt; <span class="st">&#39;client_name&#39;</span><span class="ot">,</span></span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true"></a>    <span class="st">&#39;meta_value&#39;</span> =&gt; <span class="st">&#39;Acme Corporation&#39;</span><span class="ot">,</span></span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true"></a><span class="ot">);</span></span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true"></a></span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true"></a><span class="kw">$portfolio_query</span> = <span class="kw">new</span> WP_Query<span class="ot">(</span><span class="kw">$args</span><span class="ot">);</span></span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true"></a></span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span><span class="kw">$portfolio_query</span>-&gt;have_posts<span class="ot">())</span> :</span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true"></a>    <span class="kw">while</span> <span class="ot">(</span><span class="kw">$portfolio_query</span>-&gt;have_posts<span class="ot">())</span> :</span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true"></a>        <span class="kw">$portfolio_query</span>-&gt;the_post<span class="ot">();</span></span>
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true"></a>        the_title<span class="ot">(</span><span class="st">&#39;&lt;h2&gt;&#39;</span><span class="ot">,</span> <span class="st">&#39;&lt;/h2&gt;&#39;</span><span class="ot">);</span></span>
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true"></a>    <span class="kw">endwhile</span><span class="ot">;</span></span>
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true"></a>    wp_reset_postdata<span class="ot">();</span></span>
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true"></a><span class="kw">endif</span><span class="ot">;</span></span>
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<p><strong>Query with Meta Comparison</strong>:</p>
<div class="sourceCode" id="cb18">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true"></a><span class="co">// Get portfolio items from 2024 or later</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true"></a><span class="kw">$args</span> = <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true"></a>    <span class="st">&#39;post_type&#39;</span>  =&gt; <span class="st">&#39;portfolio&#39;</span><span class="ot">,</span></span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true"></a>    <span class="st">&#39;meta_query&#39;</span> =&gt; <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true"></a>            <span class="st">&#39;key&#39;</span>     =&gt; <span class="st">&#39;project_date&#39;</span><span class="ot">,</span></span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true"></a>            <span class="st">&#39;value&#39;</span>   =&gt; <span class="st">&#39;2024-01-01&#39;</span><span class="ot">,</span></span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true"></a>            <span class="st">&#39;compare&#39;</span> =&gt; <span class="st">&#39;&gt;=&#39;</span><span class="ot">,</span></span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true"></a>            <span class="st">&#39;type&#39;</span>    =&gt; <span class="st">&#39;DATE&#39;</span><span class="ot">,</span></span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true"></a>        <span class="ot">),</span></span>
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true"></a>    <span class="ot">),</span></span>
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true"></a><span class="ot">);</span></span>
<span id="cb18-14"><a href="#cb18-14" aria-hidden="true"></a></span>
<span id="cb18-15"><a href="#cb18-15" aria-hidden="true"></a><span class="kw">$recent_portfolio</span> = <span class="kw">new</span> WP_Query<span class="ot">(</span><span class="kw">$args</span><span class="ot">);</span></span>
<span id="cb18-16"><a href="#cb18-16" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<p><strong>Multiple Meta Queries</strong>:</p>
<div class="sourceCode" id="cb19">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true"></a><span class="kw">$args</span> = <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true"></a>    <span class="st">&#39;post_type&#39;</span>  =&gt; <span class="st">&#39;portfolio&#39;</span><span class="ot">,</span></span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true"></a>    <span class="st">&#39;meta_query&#39;</span> =&gt; <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true"></a>        <span class="st">&#39;relation&#39;</span> =&gt; <span class="st">&#39;AND&#39;</span><span class="ot">,</span></span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true"></a>            <span class="st">&#39;key&#39;</span>     =&gt; <span class="st">&#39;client_name&#39;</span><span class="ot">,</span></span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true"></a>            <span class="st">&#39;value&#39;</span>   =&gt; <span class="st">&#39;Acme&#39;</span><span class="ot">,</span></span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true"></a>            <span class="st">&#39;compare&#39;</span> =&gt; <span class="st">&#39;LIKE&#39;</span><span class="ot">,</span></span>
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true"></a>        <span class="ot">),</span></span>
<span id="cb19-11"><a href="#cb19-11" aria-hidden="true"></a>        <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb19-12"><a href="#cb19-12" aria-hidden="true"></a>            <span class="st">&#39;key&#39;</span>     =&gt; <span class="st">&#39;project_date&#39;</span><span class="ot">,</span></span>
<span id="cb19-13"><a href="#cb19-13" aria-hidden="true"></a>            <span class="st">&#39;value&#39;</span>   =&gt; <span class="st">&#39;2024-01-01&#39;</span><span class="ot">,</span></span>
<span id="cb19-14"><a href="#cb19-14" aria-hidden="true"></a>            <span class="st">&#39;compare&#39;</span> =&gt; <span class="st">&#39;&gt;=&#39;</span><span class="ot">,</span></span>
<span id="cb19-15"><a href="#cb19-15" aria-hidden="true"></a>            <span class="st">&#39;type&#39;</span>    =&gt; <span class="st">&#39;DATE&#39;</span><span class="ot">,</span></span>
<span id="cb19-16"><a href="#cb19-16" aria-hidden="true"></a>        <span class="ot">),</span></span>
<span id="cb19-17"><a href="#cb19-17" aria-hidden="true"></a>    <span class="ot">),</span></span>
<span id="cb19-18"><a href="#cb19-18" aria-hidden="true"></a><span class="ot">);</span></span>
<span id="cb19-19"><a href="#cb19-19" aria-hidden="true"></a></span>
<span id="cb19-20"><a href="#cb19-20" aria-hidden="true"></a><span class="kw">$filtered_portfolio</span> = <span class="kw">new</span> WP_Query<span class="ot">(</span><span class="kw">$args</span><span class="ot">);</span></span>
<span id="cb19-21"><a href="#cb19-21" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<h2 id="programmatic-field-registration">Programmatic Field Registration</h2>
<p><strong>Register Fields via PHP</strong> (functions.php):</p>
<div class="sourceCode" id="cb20">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true"></a><span class="kw">function</span> mytheme_register_acf_fields<span class="ot">()</span> {</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true"></a>    <span class="kw">if</span> <span class="ot">(</span><span class="fu">function_exists</span><span class="ot">(</span><span class="st">&#39;acf_add_local_field_group&#39;</span><span class="ot">))</span> {</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true"></a>        acf_add_local_field_group<span class="ot">(</span><span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true"></a>            <span class="st">&#39;key&#39;</span>    =&gt; <span class="st">&#39;group_portfolio&#39;</span><span class="ot">,</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true"></a>            <span class="st">&#39;title&#39;</span>  =&gt; <span class="st">&#39;Portfolio Fields&#39;</span><span class="ot">,</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true"></a>            <span class="st">&#39;fields&#39;</span> =&gt; <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true"></a>                <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true"></a>                    <span class="st">&#39;key&#39;</span>   =&gt; <span class="st">&#39;field_client_name&#39;</span><span class="ot">,</span></span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true"></a>                    <span class="st">&#39;label&#39;</span> =&gt; <span class="st">&#39;Client Name&#39;</span><span class="ot">,</span></span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true"></a>                    <span class="st">&#39;name&#39;</span>  =&gt; <span class="st">&#39;client_name&#39;</span><span class="ot">,</span></span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true"></a>                    <span class="st">&#39;type&#39;</span>  =&gt; <span class="st">&#39;text&#39;</span><span class="ot">,</span></span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true"></a>                    <span class="st">&#39;required&#39;</span> =&gt; <span class="dv">1</span><span class="ot">,</span></span>
<span id="cb20-13"><a href="#cb20-13" aria-hidden="true"></a>                <span class="ot">),</span></span>
<span id="cb20-14"><a href="#cb20-14" aria-hidden="true"></a>                <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-15"><a href="#cb20-15" aria-hidden="true"></a>                    <span class="st">&#39;key&#39;</span>   =&gt; <span class="st">&#39;field_project_url&#39;</span><span class="ot">,</span></span>
<span id="cb20-16"><a href="#cb20-16" aria-hidden="true"></a>                    <span class="st">&#39;label&#39;</span> =&gt; <span class="st">&#39;Project URL&#39;</span><span class="ot">,</span></span>
<span id="cb20-17"><a href="#cb20-17" aria-hidden="true"></a>                    <span class="st">&#39;name&#39;</span>  =&gt; <span class="st">&#39;project_url&#39;</span><span class="ot">,</span></span>
<span id="cb20-18"><a href="#cb20-18" aria-hidden="true"></a>                    <span class="st">&#39;type&#39;</span>  =&gt; <span class="st">&#39;url&#39;</span><span class="ot">,</span></span>
<span id="cb20-19"><a href="#cb20-19" aria-hidden="true"></a>                <span class="ot">),</span></span>
<span id="cb20-20"><a href="#cb20-20" aria-hidden="true"></a>                <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-21"><a href="#cb20-21" aria-hidden="true"></a>                    <span class="st">&#39;key&#39;</span>   =&gt; <span class="st">&#39;field_project_date&#39;</span><span class="ot">,</span></span>
<span id="cb20-22"><a href="#cb20-22" aria-hidden="true"></a>                    <span class="st">&#39;label&#39;</span> =&gt; <span class="st">&#39;Project Date&#39;</span><span class="ot">,</span></span>
<span id="cb20-23"><a href="#cb20-23" aria-hidden="true"></a>                    <span class="st">&#39;name&#39;</span>  =&gt; <span class="st">&#39;project_date&#39;</span><span class="ot">,</span></span>
<span id="cb20-24"><a href="#cb20-24" aria-hidden="true"></a>                    <span class="st">&#39;type&#39;</span>  =&gt; <span class="st">&#39;date_picker&#39;</span><span class="ot">,</span></span>
<span id="cb20-25"><a href="#cb20-25" aria-hidden="true"></a>                    <span class="st">&#39;display_format&#39;</span> =&gt; <span class="st">&#39;d/m/Y&#39;</span><span class="ot">,</span></span>
<span id="cb20-26"><a href="#cb20-26" aria-hidden="true"></a>                    <span class="st">&#39;return_format&#39;</span>  =&gt; <span class="st">&#39;Y-m-d&#39;</span><span class="ot">,</span></span>
<span id="cb20-27"><a href="#cb20-27" aria-hidden="true"></a>                <span class="ot">),</span></span>
<span id="cb20-28"><a href="#cb20-28" aria-hidden="true"></a>                <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-29"><a href="#cb20-29" aria-hidden="true"></a>                    <span class="st">&#39;key&#39;</span>   =&gt; <span class="st">&#39;field_technologies&#39;</span><span class="ot">,</span></span>
<span id="cb20-30"><a href="#cb20-30" aria-hidden="true"></a>                    <span class="st">&#39;label&#39;</span> =&gt; <span class="st">&#39;Technologies Used&#39;</span><span class="ot">,</span></span>
<span id="cb20-31"><a href="#cb20-31" aria-hidden="true"></a>                    <span class="st">&#39;name&#39;</span>  =&gt; <span class="st">&#39;technologies&#39;</span><span class="ot">,</span></span>
<span id="cb20-32"><a href="#cb20-32" aria-hidden="true"></a>                    <span class="st">&#39;type&#39;</span>  =&gt; <span class="st">&#39;checkbox&#39;</span><span class="ot">,</span></span>
<span id="cb20-33"><a href="#cb20-33" aria-hidden="true"></a>                    <span class="st">&#39;choices&#39;</span> =&gt; <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-34"><a href="#cb20-34" aria-hidden="true"></a>                        <span class="st">&#39;wordpress&#39;</span>  =&gt; <span class="st">&#39;WordPress&#39;</span><span class="ot">,</span></span>
<span id="cb20-35"><a href="#cb20-35" aria-hidden="true"></a>                        <span class="st">&#39;php&#39;</span>        =&gt; <span class="st">&#39;PHP&#39;</span><span class="ot">,</span></span>
<span id="cb20-36"><a href="#cb20-36" aria-hidden="true"></a>                        <span class="st">&#39;javascript&#39;</span> =&gt; <span class="st">&#39;JavaScript&#39;</span><span class="ot">,</span></span>
<span id="cb20-37"><a href="#cb20-37" aria-hidden="true"></a>                        <span class="st">&#39;react&#39;</span>      =&gt; <span class="st">&#39;React&#39;</span><span class="ot">,</span></span>
<span id="cb20-38"><a href="#cb20-38" aria-hidden="true"></a>                    <span class="ot">),</span></span>
<span id="cb20-39"><a href="#cb20-39" aria-hidden="true"></a>                <span class="ot">),</span></span>
<span id="cb20-40"><a href="#cb20-40" aria-hidden="true"></a>            <span class="ot">),</span></span>
<span id="cb20-41"><a href="#cb20-41" aria-hidden="true"></a>            <span class="st">&#39;location&#39;</span> =&gt; <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-42"><a href="#cb20-42" aria-hidden="true"></a>                <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-43"><a href="#cb20-43" aria-hidden="true"></a>                    <span class="kw">array</span><span class="ot">(</span></span>
<span id="cb20-44"><a href="#cb20-44" aria-hidden="true"></a>                        <span class="st">&#39;param&#39;</span>    =&gt; <span class="st">&#39;post_type&#39;</span><span class="ot">,</span></span>
<span id="cb20-45"><a href="#cb20-45" aria-hidden="true"></a>                        <span class="st">&#39;operator&#39;</span> =&gt; <span class="st">&#39;==&#39;</span><span class="ot">,</span></span>
<span id="cb20-46"><a href="#cb20-46" aria-hidden="true"></a>                        <span class="st">&#39;value&#39;</span>    =&gt; <span class="st">&#39;portfolio&#39;</span><span class="ot">,</span></span>
<span id="cb20-47"><a href="#cb20-47" aria-hidden="true"></a>                    <span class="ot">),</span></span>
<span id="cb20-48"><a href="#cb20-48" aria-hidden="true"></a>                <span class="ot">),</span></span>
<span id="cb20-49"><a href="#cb20-49" aria-hidden="true"></a>            <span class="ot">),</span></span>
<span id="cb20-50"><a href="#cb20-50" aria-hidden="true"></a>        <span class="ot">));</span></span>
<span id="cb20-51"><a href="#cb20-51" aria-hidden="true"></a>    }</span>
<span id="cb20-52"><a href="#cb20-52" aria-hidden="true"></a>}</span>
<span id="cb20-53"><a href="#cb20-53" aria-hidden="true"></a>add_action<span class="ot">(</span><span class="st">&#39;acf/init&#39;</span><span class="ot">,</span> <span class="st">&#39;mytheme_register_acf_fields&#39;</span><span class="ot">);</span></span></code></pre>
</div>
<h2 id="helper-functions">Helper Functions</h2>
<p><strong>Check if Field Has Value</strong>:</p>
<div class="sourceCode" id="cb21">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true"></a><span class="kw">if</span> <span class="ot">(</span>get_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">))</span> {</span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true"></a>    <span class="kw">echo</span> <span class="st">&#39;Client: &#39;</span> . esc_html<span class="ot">(</span>get_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">));</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true"></a>}</span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<p><strong>Field Shorthand</strong>:</p>
<div class="sourceCode" id="cb22">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true"></a><span class="co">// Get and echo in one function</span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true"></a>the_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">);</span></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true"></a></span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true"></a><span class="co">// Equivalent to:</span></span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true"></a><span class="kw">echo</span> get_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">);</span></span>
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<p><strong>Get Field from Specific Post</strong>:</p>
<div class="sourceCode" id="cb23">
<pre class="sourceCode php"><code class="sourceCode php"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true"></a><span class="kw">&lt;?php</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true"></a><span class="kw">$client</span> = get_field<span class="ot">(</span><span class="st">&#39;client_name&#39;</span><span class="ot">,</span> <span class="dv">123</span><span class="ot">);</span> <span class="co">// Post ID 123</span></span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true"></a><span class="kw">?&gt;</span></span></code></pre>
</div>
<h2 id="conclusion">Conclusion</h2>
<p>Advanced Custom Fields transforms WordPress custom post types into robust content management systems through intuitive field group interfaces eliminating custom database development. Register custom post types with register_post_type(), create field groups via ACF admin interface, display fields in templates using get_field() and the_field(), query posts by meta values with WP_Query meta_query parameters, and optionally register fields programmatically with acf_add_local_field_group(). ACF enables complex data structures maintaining WordPress simplicity and flexibility.</p>
<h2 id="external-links">External Links</h2>
<ol type="1">
<li><a href="https://www.advancedcustomfields.com/resources/">ACF Documentation</a></li>
<li><a href="https://www.advancedcustomfields.com/resources/#field-types">ACF Field Types</a></li>
<li><a href="https://www.advancedcustomfields.com/resources/get_field/">get_field() Reference</a></li>
<li><a href="https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters">WP_Query Meta Parameters</a></li>
<li><a href="https://developer.wordpress.org/reference/functions/register_post_type/">Register Post Type</a></li>
</ol>
<h2 id="call-to-action">Call to Action</h2>
<p>Custom fields need reliable backups. <a href="https://backupcopilotplugin.com/">Backup Copilot Pro</a> protects your WordPress ACF configurations and custom post type data automatically. Safeguard your content structures—start your free 30-day trial today!</p>
<p>The post <a href="https://developryplugins.com/acf-tutorial-building-custom-post-types-with-advanced-custom-fields/">ACF Tutorial: Building Custom Post Types with Advanced Custom Fields</a> appeared first on <a href="https://developryplugins.com">Developry Plugins</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
