<?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>Functions - ThemesPress</title>
	<atom:link href="https://themespress.ca/en/sujets/functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://themespress.ca/en/</link>
	<description>Experts en développement d’API, plugins et intégrations WordPress.</description>
	<lastBuildDate>Sat, 01 Oct 2022 19:06:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://themespress.ca/wp-content/uploads/2020/10/cropped-Favicon-Themepress.ca_-32x32.png</url>
	<title>Functions - ThemesPress</title>
	<link>https://themespress.ca/en/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Creating a Query Post Shortcode for WordPress</title>
		<link>https://themespress.ca/en/creating-query-post-shortcode/</link>
					<comments>https://themespress.ca/en/creating-query-post-shortcode/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Fri, 24 Jun 2022 18:25:53 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Query]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6294</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will create a shortcode that will return the results of a WordPress query.</p>
<p>We will be creating a <a title="Add Shortcode" href="https://codex.wordpress.org/Function_Reference/add_shortcode" target="_blank" rel="noopener">add_shortcode</a> shortcode that will contain the shortcode name and function as parameters.<br />
With this example, we will call a query for a Video post type sorted by number of likes.</p>
<p>We edited the get option inside the shortcode if you have options. Then we run the new WP_Query.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-1924969" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-1924969" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php
// Creation du shortcode permettant de lister la liste des videos class&eacute;es par nombre de likes
add_shortcode( &#039;viavideoslikes&#039;, &#039;via_videos_list_likes_shortcode&#039; );
function via_videos_list_likes_shortcode( $atts ) {
	ob_start();
	$options = get_option(&#039;via_video_name&#039;);
	$query = new WP_Query( array(
		&#039;post_type&#039;            =&gt; &#039;viavideos&#039;,
		&#039;meta_key&#039;             =&gt; &#039;_post_like_count&#039;,
		&#039;orderby&#039;              =&gt; &#039;meta_value_num&#039;,
        &#039;order&#039;                =&gt; &#039;DESC&#039;,
		&#039;posts_per_page&#039;       =&gt; -1,
		) );
	if ( $query-&amp;gt;have_posts() ) { 
	?&gt;
	
	
	&lt;?php while ( $query-&gt;have_posts() ) : $query-&gt;the_post(); ?&gt;

	
        // Afficher ici votre contenu dynamique dans vos contenants div


	&lt;?php endwhile; wp_reset_postdata(); ?&gt;
	&lt;?php $myvariable = ob_get_clean();
	return $myvariable;
	}
}</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Creating a Query Post Shortcode for WordPress</h2><div id="ts-enlighterjs-container-3844253" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3844253" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">[viavideoslikes]</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Or in a template page</h2><div id="ts-enlighterjs-container-8866794" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-8866794" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php echo do_shortcode(&#039;[viavideoslikes]&#039;); ?&gt;</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/creating-query-post-shortcode/">Creating a Query Post Shortcode for WordPress</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/creating-query-post-shortcode/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Calculate Post Meta Key &#8211; Post Type Percentage</title>
		<link>https://themespress.ca/en/post-meta-key-post-type-percent/</link>
					<comments>https://themespress.ca/en/post-meta-key-post-type-percent/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sun, 13 Mar 2022 18:31:12 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6330</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Calcul Pourcentage Post Meta Key – Post Type :<br />
This tutorial will allow you to calculate the total percentage (Num) of a Meta post of Post type&#8217;s 100%.</p>

		</div>
	</div>

	<div  class="wpb_single_image wpb_content_element vc_align_left wpb_content_element">
		
		<figure class="wpb_wrapper vc_figure">
			<div class="vc_single_image-wrapper   vc_box_border_grey"><img fetchpriority="high" decoding="async" width="335" height="640" src="https://themespress.ca/wp-content/uploads/2016/03/exemple-pourcentage-1.jpg" class="vc_single_image-img attachment-full" alt="" title="exemple-pourcentage" srcset="https://themespress.ca/wp-content/uploads/2016/03/exemple-pourcentage-1.jpg 335w, https://themespress.ca/wp-content/uploads/2016/03/exemple-pourcentage-1-157x300.jpg 157w" sizes="(max-width: 335px) 100vw, 335px" /></div>
		</figure>
	</div>

<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>In our example, we using a viavideos post type. We have various meta posts that will allow us to fetch the video&#8217;s language.</p>
<p>We want to display the video&#8217;s percentage in a language according to the total number of videos.</p>
<p>We also have a calc function in our files and display example for a language meta post. This tutorial is well documented and explains what it displays.</p>
<p><strong>Note</strong>: The progress bar is displayed via a CSS bootstrap. Simply add the CSS line in your header or user your own progress bar.</p>
<p><a href="https://themespress.ca/produits/ressources/calcul-pourcentage-post-meta-post-type/">Calculate Post Meta Key &#8211; Post Type percentage</a></p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/post-meta-key-post-type-percent/">Calculate Post Meta Key – Post Type Percentage</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/post-meta-key-post-type-percent/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress Search Function</title>
		<link>https://themespress.ca/en/wordpress-search-function/</link>
					<comments>https://themespress.ca/en/wordpress-search-function/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sun, 06 Feb 2022 20:38:51 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6411</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Sometimes, it is possible that you experience query issues occur especially with Custom Post Type. Here&#8217;s a solution to address this issue.<br />
Here&#8217;s a function that do an advanced search to optimize your users&#8217; searches on your website. First of all, make sure that the searchform.php is triggered properly.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-3807781" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-3807781" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;form id=&quot;searchform&quot; role=&quot;search&quot; action=&quot;&lt;?php echo home_url( &#039;/&#039; ); ?&gt;&quot; method=&quot;get&quot;&gt;&lt;input id=&quot;s&quot; name=&quot;s&quot; type=&quot;text&quot; value=&quot;&lt;?php the_search_query(); ?&gt;&quot; /&gt; &lt;input id=&quot;searchsubmit&quot; type=&quot;submit&quot; value=&quot;&quot; /&gt;&lt;/form&gt;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Afterwards you need to add a function filter to your functions.php file.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-1210452" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-1210452" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="standard" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">///////////////////////////////////////
// Requete de recherche mots cl&eacute;s tous post
///////////////////////////////////////
function searchfilter($query) {
 
if ($query-&gt;is_search &amp;&amp; !is_admin() ) {
$query-&gt;set(&#039;post_type&#039;,array(&#039;post&#039;,&#039;recettes&#039;));
}
 
return $query;
}
add_filter(&#039;pre_get_posts&#039;,&#039;searchfilter&#039;);</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>You&#8217;ll notice that with this filter, we do a query on general posts but also a Custom Post Type. Simply replace the Custom Post Type by yours.</p>
<p>Let&#8217;s image that we have a second Custom Post Type called portfolio, so how can we add it after the first one?</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6174687" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6174687" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">///////////////////////////////////////
// Requete de recherche mots cl&eacute;s tous post
///////////////////////////////////////
function searchfilter($query) {
 
if ($query-&gt;is_search &amp;&amp; !is_admin() ) {
$query-&gt;set(&#039;post_type&#039;,array(&#039;post&#039;,&#039;recettes&#039;,&#039;portfolio&#039;));
}
 
return $query;
}
add_filter(&#039;pre_get_posts&#039;,&#039;searchfilter&#039;);</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Your search.php will display the results.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/wordpress-search-function/">WordPress Search Function</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/wordpress-search-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Shortcode to Obtain a Post&#8217;s ID</title>
		<link>https://themespress.ca/en/creating-a-shortcode-to-obtain-a-posts-id/</link>
					<comments>https://themespress.ca/en/creating-a-shortcode-to-obtain-a-posts-id/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Wed, 11 Jul 2018 13:18:08 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Posts]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5015</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will create a shortcode that will allow us to fetch the ID of the current post. This shortcode is often referred to as <strong>current post id </strong>. For example, this can be used to fetch a param and get the value in order to stash it in a form.</p>
<p>We will need to add this shortcode into our <strong>functions.php</strong> file and will return the current post id.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-4456319" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4456319" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">//[thepostid]
function thepostidfunc( $atts ){
         global $post;
         return $post-&gt;ID;   
}
add_shortcode( &#039;thepostid&#039;, &#039;thepostidfunc&#039; );</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Puis vous pouvez l’appeler de cette façon :</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-8053593" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-8053593" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php echo do_shortcode( &#039;[thepostid]&#039; ); ?&gt;</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/creating-a-shortcode-to-obtain-a-posts-id/">Creating a Shortcode to Obtain a Post’s ID</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/creating-a-shortcode-to-obtain-a-posts-id/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Randomly Display Taxonomy Terms</title>
		<link>https://themespress.ca/en/randomly-display-taxonomy-terms/</link>
					<comments>https://themespress.ca/en/randomly-display-taxonomy-terms/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Tue, 01 May 2018 13:32:27 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Taxonomy]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5020</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we&#8217;re going to show you how to display randomly display taxonomies. For example, we&#8217;ll create a Post Type called Event whose taxonomy will be Event Type. We consult an Event page and under its results, we want to randomly display additional taxonomy except for the one we&#8217;re currently viewing.</p>
<p>They are like similar terms, but random.</p>
<p>For our example:<br />
Post Type: <strong>Events</strong><br />
Taxonomy: <strong>Event type (must be the same as the category name)</strong><br />
Template used: <strong>taxonomy-type-evenements.php</strong></p>
<p>Thus we will create a query that will allow us to do so. We will use the <a href="https://developer.wordpress.org/reference/functions/get_terms/" target="_blank" rel="noopener"><strong>get_terms</strong></a> function and add our args. Afterwards, we will get a random result and we will indicate how many results to return. To display the results, we close the loop with a <strong>foreach</strong> for every term.</p>
<p>We also must not forget to exclude the term we are currently consulting with the <strong>get_queried_object_id();</strong> that we use with our variable before the get_terms.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Randomly Display Taxonomy Terms</h2><div id="ts-enlighterjs-container-6802463" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6802463" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php 
    //Get all terms 
	$currentid = get_queried_object_id(); 
	$terms = get_terms( array( 
	&#039;taxonomy&#039;      =&gt; &#039;type-evenements&#039;,
	&#039;hide_empty&#039;    =&gt; false,
	&#039;exclude&#039;       =&gt; array($currentid)
	) );
	// Randomize Term Array
	shuffle( $terms );
	// Grab Indices 0 - 5, 6 in total
	$randterms = array_slice( $terms, 0, 2 );
?&gt;
&lt;?php foreach ($randterms as $term) { ?&gt;
&lt;?php /// Votre div dynamique d&eacute;sir&eacute;e ?&gt;
&lt;?php endforeach; wp_reset_postdata(); ?&gt;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>So by using get_terms, make sure to change the args for yours without adding any new ones.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/randomly-display-taxonomy-terms/">Randomly Display Taxonomy Terms</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/randomly-display-taxonomy-terms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress: Template page Post Type &#038; Redirect or Create An Page Archive Post Type</title>
		<link>https://themespress.ca/en/wordpress-template-page-post-type-redirect-or-create-an-page-archive-post-type/</link>
					<comments>https://themespress.ca/en/wordpress-template-page-post-type-redirect-or-create-an-page-archive-post-type/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 05 Apr 2018 22:27:40 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5067</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will create a redirect that forces a Post Type template to use a WordPress page by using template_redirect.</p>
<p>The first step is to create your Post Type page template. For example, if you&#8217;re using the term team, you&#8217;ll need a template-equipe.php page template.</p>
<p>In your function, you&#8217;ll only need one condition: that it needs a page called <strong>Your Team</strong> that uses the page template created above. Your page needs to have the your-team slug i.e. the full URL should be <strong>https://www.domain-name.com/your-team</strong>.</p>
<p>What&#8217;s interesting with using Post Type template pages is that you can set it apart from the index and archive.php files allowing you to customize it by fetching results from a custom loop query.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Votre page template Post Type (Un exemple) :</h2><div id="ts-enlighterjs-container-4789286" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4789286" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php
/**
* Template Name: Equipe
* @package WordPress
* @subpackage Nom du Theme
* @since Nom du Theme 1.0
*/
?&gt;
&lt;?php get_header(); ?&gt;
&lt;!--Page start--&gt;
&lt;div class=&quot;service_in&quot;&gt;
&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;col-md-12&quot;&gt;
&lt;div class=&quot;service_txt&quot;&gt;
&lt;div class=&quot;col-md-9 col-sm-6 col-xs-12&quot;&gt;
&lt;h4&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div class=&quot;row&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!--Page end--&gt; 

&lt;?php include( get_template_directory() . &#039;/templates-part/part-blog.php&#039;); ?&gt;
&lt;?php get_footer(); ?&gt;</pre></div><h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Create a wp_redirect for an archive template page:</h2><div id="ts-enlighterjs-container-2289328" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-2289328" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">&lt;?php
function votretheme_redirect_cpt_archive() {
    if( is_post_type_archive( &#039;equipe&#039; ) ) {
        wp_redirect( home_url( &#039;votre-equipe&#039; ), 301 );
        exit();
    }
}
add_action( &#039;template_redirect&#039;, &#039;votretheme_redirect_cpt_archive&#039; );
 ?&gt;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Alternatively, if you do not want to create a template page and a redirect, simply create an archvie page named with your Post Type such as <strong>Team</strong> which would translate to <strong>archive-equipe.php</strong>.</p>

		</div>
	</div>

	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>In this case, a redirect is not necessary as WordPress will automatically use the <strong>archive-equipe.php</strong> template.</p>
<p>You can use the same condition for other customed archives. If you do not use a Post Type template, WordPress will use the archive.php and its loop.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/wordpress-template-page-post-type-redirect-or-create-an-page-archive-post-type/">WordPress: Template page Post Type & Redirect or Create An Page Archive Post Type</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/wordpress-template-page-post-type-redirect-or-create-an-page-archive-post-type/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Duplicate Articles Without Plugins</title>
		<link>https://themespress.ca/en/how-to-duplicate-articles-without-plugins/</link>
					<comments>https://themespress.ca/en/how-to-duplicate-articles-without-plugins/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Wed, 28 Feb 2018 19:07:19 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5085</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will use a function that will allow you to duplicate a WordPress post without using a plugin. Admins can easily duplicate a draft to save time.</p>
<p>It is important to understand that while duplicating is a time-saver, we have to be careful with the next post. We need to double-check the URL&#8217;s slug in the duplicated post because it will have the same URL with a -2 appended to it meaning you&#8217;ll need to tailor it based on the newest post.</p>
<p>In our function if we do an <strong>isset get post</strong>, we&#8217;ll first validate if the user has admin rights. And then we fetch the previous post&#8217;s attributes and afterwards we use <a href="https://developer.wordpress.org/reference/functions/wp_insert_post/" target="_blank" rel="noopener">wp_insert_post</a> in order to recuperate taxonomy and category information. Finally, we validate and fetch all of the posts&#8217; meta and add them into an SQL query. </p>

		</div>
	</div>
</div></div></div></div><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper"><div id="ts-enlighterjs-container-9229734" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-9229734" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">function themepress_duplicate_post_as_draft(){
	global $wpdb;
	if (! ( isset( $_GET[&#039;post&#039;]) || isset( $_POST[&#039;post&#039;])  || ( isset($_REQUEST[&#039;action&#039;]) &amp;&amp; &#039;themepress_duplicate_post_as_draft&#039; == $_REQUEST[&#039;action&#039;] ) ) ) {
	wp_die(&#039;No post to duplicate has been supplied!&#039;);
	}
 
	/*
	 * get the original post id
	 */
	$post_id = (isset($_GET[&#039;post&#039;]) ? $_GET[&#039;post&#039;] : $_POST[&#039;post&#039;]);
	/*
	 * and all the original post data then
	 */
	$post = get_post( $post_id );
 
	/*
	 * if you don&#039;t want current user to be the new post author,
	 * then change next couple of lines to this: $new_post_author = $post-&gt;post_author;
	 */
	$current_user = wp_get_current_user();
	$new_post_author = $current_user-&gt;ID;
 
	/*
	 * if post data exists, create the post duplicate
	 */
	 if (isset( $post ) &amp;&amp; $post != null) {
 
		/*
		 * new post data array
		 */
		$args = array(
			&#039;comment_status&#039; =&gt; $post-&gt;comment_status,
			&#039;ping_status&#039;    =&gt; $post-&gt;ping_status,
			&#039;post_author&#039;    =&gt; $new_post_author,
			&#039;post_content&#039;   =&gt; $post-&gt;post_content,
			&#039;post_excerpt&#039;   =&gt; $post-&gt;post_excerpt,
			&#039;post_name&#039;      =&gt; $post-&gt;post_name,
			&#039;post_parent&#039;    =&gt; $post-&gt;post_parent,
			&#039;post_passwothemepress&#039;  =&gt; $post-&gt;post_passwothemepress,
			&#039;post_status&#039;    =&gt; &#039;draft&#039;,
			&#039;post_title&#039;     =&gt; $post-&gt;post_title,
			&#039;post_type&#039;      =&gt; $post-&gt;post_type,
			&#039;to_ping&#039;        =&gt; $post-&gt;to_ping,
			&#039;menu_othemepresser&#039;     =&gt; $post-&gt;menu_othemepresser
		);
 
		/*
		 * insert the post by wp_insert_post() function
		 */
		$new_post_id = wp_insert_post( $args );
 
		/*
		 * get all current post terms ad set them to the new post draft
		 */
		$taxonomies = get_object_taxonomies($post-&gt;post_type); // returns array of taxonomy names for post type, ex array(&quot;category&quot;, &quot;post_tag&quot;);
		foreach ($taxonomies as $taxonomy) {
			$post_terms = wp_get_object_terms($post_id, $taxonomy, array(&#039;fields&#039; =&gt; &#039;slugs&#039;));
			wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
		}
 
		/*
		 * duplicate all post meta just in two SQL queries
		 */
		$post_meta_infos = $wpdb-&gt;get_results(&quot;SELECT meta_key, meta_value FROM $wpdb-&gt;postmeta WHERE post_id=$post_id&quot;);
		if (count($post_meta_infos)!=0) {
			$sql_query = &quot;INSERT INTO $wpdb-&gt;postmeta (post_id, meta_key, meta_value) &quot;;
			foreach ($post_meta_infos as $meta_info) {
				$meta_key = $meta_info-&gt;meta_key;
				$meta_value = addslashes($meta_info-&gt;meta_value);
				$sql_query_sel[]= &quot;SELECT $new_post_id, &#039;$meta_key&#039;, &#039;$meta_value&#039;&quot;;
			}
			$sql_query.= implode(&quot; UNION ALL &quot;, $sql_query_sel);
			$wpdb-&gt;query($sql_query);
		}
		/*
		 * finally, redirect to the edit post screen for the new draft
		 */
		wp_redirect( admin_url( &#039;post.php?action=edit&amp;amp;post=&#039; . $new_post_id ) );
		exit;
	} else {
		wp_die(&#039;Post creation failed, could not find original post: &#039; . $post_id);
	}
}
add_action( &#039;admin_action_themepress_duplicate_post_as_draft&#039;, &#039;themepress_duplicate_post_as_draft&#039; );
 
/*
 * Add the duplicate link to action list for post_row_actions
 */
function themepress_duplicate_post_link( $actions, $post ) {
	if (current_user_can(&#039;edit_posts&#039;)) {
		$actions[&#039;duplicate&#039;] = &#039;&lt;a title=&quot;Dupliquer&quot; href=&quot;admin.php?action=themepress_duplicate_post_as_draft&amp;amp;post=&#039; . $post-&gt;ID . &#039;&quot; rel=&quot;permalink&quot;&gt;Duplicate&lt;/a&gt;&#039;;
	}
	return $actions;
}
 
add_filter( &#039;post_row_actions&#039;, &#039;themepress_duplicate_post_link&#039;, 10, 2 );
add_filter( &#039;page_row_actions&#039;, &#039;themepress_duplicate_post_link&#039;, 10, 2 );</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>We noticed that once the requirements have been filled, we enable the filter where we need it. In this case, we have two filters: <a href="https://developer.wordpress.org/reference/hooks/post_row_actions/" target="_blank" rel="noopener">post_row_actions</a> and <a href="https://developer.wordpress.org/reference/hooks/page_row_actions-6/" target="_blank" rel="noopener">page_row_actions</a>. One for the post and the other for the pages meaning that duplication will be enabled for both types.<br />
If you want to do it for another post type such as Portfolio or testimonial, you&#8217;ll a filter similar to this: add_filter( ‘<strong>nomdutypedepost</strong>_row_actions’, ‘themepress_duplicate_post_link’, 10, 2 ); after the two other filters.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/how-to-duplicate-articles-without-plugins/">How to Duplicate Articles Without Plugins</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/how-to-duplicate-articles-without-plugins/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Display a Specific Link if User Has Post Published</title>
		<link>https://themespress.ca/en/display-a-specific-link-if-user-has-post-published/</link>
					<comments>https://themespress.ca/en/display-a-specific-link-if-user-has-post-published/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 19 Oct 2017 13:22:21 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5132</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With this tutorial, we will show you how to display a specific menu item if a user has a Post Type published.</p>
<p>First we need to create a function that will allows us to create a query that will return the number of Post Type published by the user. In this example below, <strong>you need to replace the Post Type by yours</strong> or the posts. We need to return this query that the result is different than 0.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-5404937" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-5404937" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">function themespress_user_has_posts($user_id) {
  $result = new WP_Query(array(
    &#039;author&#039;           =&gt; $user_id,
    &#039;post_type&#039;        =&gt; &#039;any&#039;,
    &#039;post_status&#039;      =&gt; &#039;publish&#039;,
    &#039;posts_per_page&#039;   =&gt; 1,
  ));
  return (count($result-&gt;posts)!=0);
}</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/display-a-specific-link-if-user-has-post-published/">Display a Specific Link if User Has Post Published</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/display-a-specific-link-if-user-has-post-published/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Display the Number of Images Attached to Post IDs</title>
		<link>https://themespress.ca/en/display-number-images-linked-to-post-id/</link>
					<comments>https://themespress.ca/en/display-number-images-linked-to-post-id/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sun, 06 Aug 2017 18:02:41 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5184</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>In this tutorial, we will create a few lines of code that will allow you to display the number of images attached to a Post ID with the help of a WordPress query.</p>
<p>First, in our query, we will need the <strong>$attachments</strong> variable which contains <a title="get_children" href="https://codex.wordpress.org/Function_Reference/get_children" target="_blank" rel="noopener">get_children</a> of all images linked to Post or Post Type. And then we create a new <strong>$count</strong> variable that will count the images.</p>
<p>With a foreach, we will display Post ID&#8217;s number of images as long as the query will find Post Ids.</p>
<p>Here&#8217;s the code to use with your Post or Post Type query.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-4031163" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-4031163" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">global $post;
$attachments = get_children ( 
   array( 
   &#039;post_parent&#039;      =&gt; $post-&gt;post_parent, 
   &#039;post_status&#039;      =&gt; &#039;inherit&#039;, 
   &#039;post_type&#039;        =&gt; &#039;attachment&#039;, 
   &#039;post_mime_type&#039;   =&gt; &#039;image&#039;, 
   &#039;order&#039;            =&gt; &#039;ASC&#039;, 
   &#039;orderby&#039;          =&gt; &#039;menu_order ID&#039; ) 
);
 
$count = count( $attachments );
$specific = array();
$i = 1;
 
foreach ( $attachments as $attachment ) {
    $specific[$attachment-&gt;ID] = $i;
    ++$i;
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>We display the results of the loop the number of images attached to the selected Post ID:</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-2391667" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-2391667" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">echo $count;</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/display-number-images-linked-to-post-id/">Display the Number of Images Attached to Post IDs</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/display-number-images-linked-to-post-id/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Creating a Custom Post Type</title>
		<link>https://themespress.ca/en/creating-a-custom-post-type/</link>
					<comments>https://themespress.ca/en/creating-a-custom-post-type/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sat, 05 Aug 2017 17:35:15 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=5191</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<div class="wpb-content-wrapper"><div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Using a Custom Post Type is a great way to separate your custom content from your post given that WordPress posts are for blogging and non necessarily custom content.</p>
<p>So for example, let&#8217;s say you want to create a new section on your website, different from the blog, titled Tutorials. In order to display them accordingly, you&#8217;ll need to create a custom Post Type.</p>
<p>Here&#8217;s how you can create your own Custom Post Type:</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6429255" class="ts-enlighterjs-container-single-enabled  " style="width: 100%;  margin-top: 0px; margin-bottom: 0px;" data-enlighter-doubleclick="true" data-enlighter-windowbutton="true" data-enlighter-windowtext="New Window" data-enlighter-rawbutton="true" data-enlighter-rawtext="RAW Code" data-enlighter-infobutton="false" data-enlighter-infotext="EnlighterJS" data-enlighter-indent="2"><pre id="ts-enlighterjs-pre-6429255" class="" style="white-space: pre-wrap; height: 100%; margin: 0; padding: 0;" data-enlighter-language="php" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">// Register Custom Post Type
function theme_custom_post_type() {
 
	$labels = array(
		&#039;name&#039;                  =&gt; _x( &#039;Post Types&#039;, &#039;Post Type General Name&#039;, &#039;text_domain&#039; ),
		&#039;singular_name&#039;         =&gt; _x( &#039;Post Type&#039;, &#039;Post Type Singular Name&#039;, &#039;text_domain&#039; ),
		&#039;menu_name&#039;             =&gt; __( &#039;Post Types&#039;, &#039;text_domain&#039; ),
		&#039;name_admin_bar&#039;        =&gt; __( &#039;Post Type&#039;, &#039;text_domain&#039; ),
		&#039;archives&#039;              =&gt; __( &#039;Item Archives&#039;, &#039;text_domain&#039; ),
		&#039;attributes&#039;            =&gt; __( &#039;Item Attributes&#039;, &#039;text_domain&#039; ),
		&#039;parent_item_colon&#039;     =&gt; __( &#039;Parent Item:&#039;, &#039;text_domain&#039; ),
		&#039;all_items&#039;             =&gt; __( &#039;All Items&#039;, &#039;text_domain&#039; ),
		&#039;add_new_item&#039;          =&gt; __( &#039;Add New Item&#039;, &#039;text_domain&#039; ),
		&#039;add_new&#039;               =&gt; __( &#039;Add New&#039;, &#039;text_domain&#039; ),
		&#039;new_item&#039;              =&gt; __( &#039;New Item&#039;, &#039;text_domain&#039; ),
		&#039;edit_item&#039;             =&gt; __( &#039;Edit Item&#039;, &#039;text_domain&#039; ),
		&#039;update_item&#039;           =&gt; __( &#039;Update Item&#039;, &#039;text_domain&#039; ),
		&#039;view_item&#039;             =&gt; __( &#039;View Item&#039;, &#039;text_domain&#039; ),
		&#039;view_items&#039;            =&gt; __( &#039;View Items&#039;, &#039;text_domain&#039; ),
		&#039;search_items&#039;          =&gt; __( &#039;Search Item&#039;, &#039;text_domain&#039; ),
		&#039;not_found&#039;             =&gt; __( &#039;Not found&#039;, &#039;text_domain&#039; ),
		&#039;not_found_in_trash&#039;    =&gt; __( &#039;Not found in Trash&#039;, &#039;text_domain&#039; ),
		&#039;featured_image&#039;        =&gt; __( &#039;Featured Image&#039;, &#039;text_domain&#039; ),
		&#039;set_featured_image&#039;    =&gt; __( &#039;Set featured image&#039;, &#039;text_domain&#039; ),
		&#039;remove_featured_image&#039; =&gt; __( &#039;Remove featured image&#039;, &#039;text_domain&#039; ),
		&#039;use_featured_image&#039;    =&gt; __( &#039;Use as featured image&#039;, &#039;text_domain&#039; ),
		&#039;insert_into_item&#039;      =&gt; __( &#039;Insert into item&#039;, &#039;text_domain&#039; ),
		&#039;uploaded_to_this_item&#039; =&gt; __( &#039;Uploaded to this item&#039;, &#039;text_domain&#039; ),
		&#039;items_list&#039;            =&gt; __( &#039;Items list&#039;, &#039;text_domain&#039; ),
		&#039;items_list_navigation&#039; =&gt; __( &#039;Items list navigation&#039;, &#039;text_domain&#039; ),
		&#039;filter_items_list&#039;     =&gt; __( &#039;Filter items list&#039;, &#039;text_domain&#039; ),
	);
	$args = array(
		&#039;label&#039;                 =&gt; __( &#039;Post Type&#039;, &#039;text_domain&#039; ),
		&#039;description&#039;           =&gt; __( &#039;Post Type Description&#039;, &#039;text_domain&#039; ),
		&#039;labels&#039;                =&gt; $labels,
		&#039;supports&#039;              =&gt; array( &#039;title&#039;, &#039;editor&#039;, &#039;excerpt&#039;, &#039;thumbnail&#039;, &#039;post-formats&#039;, ),
		&#039;taxonomies&#039;            =&gt; array( &#039;category&#039;, &#039;post_tag&#039; ),
		&#039;hierarchical&#039;          =&gt; false,
		&#039;public&#039;                =&gt; true,
		&#039;show_ui&#039;               =&gt; true,
		&#039;show_in_menu&#039;          =&gt; true,
		&#039;menu_position&#039;         =&gt; 5,
		&#039;show_in_admin_bar&#039;     =&gt; true,
		&#039;show_in_nav_menus&#039;     =&gt; true,
		&#039;can_export&#039;            =&gt; true,
		&#039;has_archive&#039;           =&gt; true,		
		&#039;exclude_from_search&#039;   =&gt; false,
		&#039;publicly_queryable&#039;    =&gt; true,
		&#039;capability_type&#039;       =&gt; &#039;page&#039;,
	);
	register_post_type( &#039;POSTTYPENAME&#039;, $args );
 
}
add_action( &#039;init&#039;, &#039;theme_custom_post_type&#039;, 0 );</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/creating-a-custom-post-type/">Creating a Custom Post Type</a> first appeared on <a href="https://themespress.ca/en/">ThemesPress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/creating-a-custom-post-type/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
