<?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>Posts - Themespress</title>
	<atom:link href="https://themespress.ca/en/sujets/posts/feed/" rel="self" type="application/rss+xml" />
	<link>https://themespress.ca/en/</link>
	<description>Des tutoriels et ressources WordPress</description>
	<lastBuildDate>Sat, 01 Oct 2022 18:30:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>

<image>
	<url>https://themespress.ca/wp-content/uploads/2020/10/cropped-Favicon-Themepress.ca_-32x32.png</url>
	<title>Posts - Themespress</title>
	<link>https://themespress.ca/en/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Number of Posts Published/Edited In the last 48 hours</title>
		<link>https://themespress.ca/en/posts-published-edited-48-hours/</link>
					<comments>https://themespress.ca/en/posts-published-edited-48-hours/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Sun, 15 Aug 2021 14:02:15 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Query]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=4887</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 learn how to create a <strong>WP Query</strong> which will return the number of posts published or edited during the last 2 days.</p>
<p>With this query, we will ping the Post Type and the results will display the Post Type counter published/edited in the last 2 days.</p>
<p>With our example, the post type is crasyphotosgalleries.<br />
We will add two arguments with the <strong><a href="https://developer.wordpress.org/reference/classes/wp_query/">date_query</a></strong>: the first one will check the <strong>post_date</strong> and/or the <strong>post_modified </strong>of the last 2 days.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Create a query - Number of posts published/edited</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>With a function we will return the results within a <a href="https://themespress.ca/categorie/tutoriels/"><strong>WordPress shortcode.</strong></a></p>

		</div>
	</div>
<div id="ts-enlighterjs-container-9953818" 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-9953818" 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="">///////////////////////////////////// Shortcode show Count Modified 48 Hours //////////////
add_shortcode( &#039;addocountpost&#039;, &#039;addo_count_posttype_modified&#039; );
function addo_count_posttype_modified(){ 
	$args = array(
		&#039;post_type&#039; =&gt; &#039;crasyphotosgalleries&#039;,
		&#039;date_query&#039; =&gt; array(
			&#039;relation&#039;   =&gt; &#039;OR&#039;,
			array(
				&#039;column&#039;  =&gt; &#039;post_date&#039;,
				&#039;after&#039;   =&gt; &#039;-2 days&#039;
			),
			array(
				&#039;column&#039;  =&gt; &#039;post_modified&#039;,
				&#039;after&#039;   =&gt; &#039;-2 days&#039;
			)
		)
	);
	// query
	$updated = new WP_Query($args);
	$totalpost = $updated-&gt;found_posts; 
        return &#039;&lt;div class=&quot;addo40px addocenter&quot;&gt;&#039; . $totalpost . &#039;&lt;/div&gt;&#039;; 
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>You can use the following shortcode in your <strong>content</strong>:</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-3005106" 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-3005106" class="ts-enlighterjs-pre-nohighlight" style="" data-enlighter-language="no-highlight" data-enlighter-theme="enlighter" data-enlighter-group="" data-enlighter-title="" data-enlighter-linenumbers="true" data-enlighter-lineoffset="1" data-enlighter-highlight="">[addocountpost]</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>You can use the following shortcode in your <strong>templates</strong>:</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-9739216" 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-9739216" 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;[addocountpost]&#039; ); ?&gt;</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/posts-published-edited-48-hours/">Number of Posts Published/Edited In the last 48 hours</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/posts-published-edited-48-hours/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Get Post/Page quantity by user role</title>
		<link>https://themespress.ca/en/get-post-page-quantity-by-user-role/</link>
					<comments>https://themespress.ca/en/get-post-page-quantity-by-user-role/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Fri, 26 Feb 2021 16:16:47 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Query]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=4189</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 new WordPress functions which will get the quantity of posts or post types by user role.<br />
In the example below, the role will be <strong>chroniqueur</strong>. If we want to add a new user role, we need a new function such as the function below. Make sure to assign users to your roles if necessary.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-2457537" 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-2457537" 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="">/**************************************** Add a new role Member ***********************************/

function themespress_role_partenaire() {  
    //add the new user role
    add_role(
        &#039;chroniqueur&#039;,
        &#039;Chroniqueur&#039;,
        array(
            &#039;read&#039;         =&gt; true,
            &#039;delete_posts&#039; =&gt; false
        )
    );
 
}
add_action(&#039;admin_init&#039;, &#039;themespress_role_partenaire&#039;);</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>And then we need to query the database by checking how many posts or post types are associated with the user. Within the function, we need to set the role with the user; you can replace news_writer by author for example.</p>
<p>With this function, we will stock the variable used to query the database for the post or post type parameter.<strong>$post_type</strong></p>

		</div>
	</div>
<div id="ts-enlighterjs-container-4017212" 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-4017212" 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 count_chahuts_by_author($post_type){
// Change here the user role
       $user_query = new WP_User_Query( array( &#039;role&#039; =&gt; &#039;chroniqueur&#039; ) );
	// Get the total number of users for the current query. I use (int) only for sanitize.
	$users_count = (int) $user_query-&gt;get_total();
	// Echo a string and the value
	return $users_count;
}</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Now we will create a shortcode that will return the value of the function above. For example our shortcode will be: [chroniqueurchahutcount]</p>
<p>For our example, the shortcode will return the quantity of <strong>chahuts</strong> post type which will match the <strong>chroniqueur</strong> user. </p>

		</div>
	</div>
<div id="ts-enlighterjs-container-1898887" 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-1898887" 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="">/////////////////////////////////////// Shortcode count chahut ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

function shortcode_chroniqueurs_count_chahut(){
$user_ID = get_current_user_id(); 
return count_chahuts_by_author($user_ID, &#039;chahuts&#039;);
}
add_shortcode(&#039;chroniqueurchahutcount&#039;, &#039;shortcode_chroniqueurs_count_chahut&#039;);</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Add your [chroniqueurchahutcount] shortcode in your template or your <a href="https://shareasale.com/r.cfm?b=841990&amp;u=1476870&amp;m=64739&amp;urllink=&amp;afftrack=" target="_blank" rel="noopener"><strong>formidable form</strong></a>.</p>
<p>Be careful as this tutorial will generate the result for a user connected with their user_id (current_user).</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/get-post-page-quantity-by-user-role/">Get Post/Page quantity by user role</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/get-post-page-quantity-by-user-role/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-9113086" 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-9113086" 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-5679293" 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-5679293" 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>Display posts related of a taxonomy slug</title>
		<link>https://themespress.ca/en/display-posts-taxonomy-slug/</link>
					<comments>https://themespress.ca/en/display-posts-taxonomy-slug/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Mon, 24 Apr 2017 17:41:46 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Posts]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6177</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><strong>Display posts related of a taxonomy slug:</strong> With this tutorial, we will create a query that will display a list of post type or posts linked to a taxonomy&#8217;s slug.</p>
<p>With our example, we will create a taxonomy which represents an artist. Our Post Type will be viavideos.</p>
<p>With the example below, we will store the args and taxonmy inside a variable and fetch it with post ID.</p>
<p>We will now create our WordPress query for the viavideos Post Type, and then we&#8217;ll add the <strong>artist</strong> taxonomy&#8217;s <strong> <a href="https://codex.wordpress.org/Class_Reference/WP_Query">tax_query</a></strong>. </p>
<p>Finally we&#8217;ll add a condition that excludes the ID of the currently viewed ID.(‘post__not_in’ =&gt; array ($post-&gt;ID)).</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6704358" 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-6704358" 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 the custom post type&#039;s taxonomy terms 
$taxonomyterms = wp_get_object_terms( $post-&gt;ID, &#039;artiste&#039;, array(&#039;fields&#039; =&gt; &#039;ids&#039;) );
// arguments
$args = array(
//Change you Post Type or post for posts WordPress
&#039;post_type&#039; =&gt; &#039;viavideos&#039;, 
&#039;post_status&#039; =&gt; &#039;publish&#039;,
&#039;posts_per_page&#039; =&gt; 3, // you may edit this number
&#039;orderby&#039; =&gt; &#039;rand&#039;,
&#039;tax_query&#039; =&gt; array(
	array(
	&#039;taxonomy&#039; =&gt; &#039;artiste&#039;,
	&#039;field&#039;    =&gt; &#039;id&#039;,
	&#039;terms&#039;    =&gt; $taxonomyterms
    )
),
&#039;post__not_in&#039; =&gt; array ($post-&gt;ID),
);
 
$related_items = new WP_Query( $args );
// loop over query
if ($related_items-&gt;have_posts()) : while ( $related_items-&gt;have_posts() ) : $related_items-&gt;the_post();
?&gt;
//// Your loop
&lt;?php endwhile; ?&gt;
&lt;?php endif; ?&gt;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Adapt this query to match your needs and add it inside your loop.</p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/display-posts-taxonomy-slug/">Display posts related of a taxonomy slug</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/display-posts-taxonomy-slug/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Count Post meta key by WordPress Post ID</title>
		<link>https://themespress.ca/en/count-post-meta-key-by-wordpress-post-id/</link>
					<comments>https://themespress.ca/en/count-post-meta-key-by-wordpress-post-id/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 30 Mar 2017 16:48:01 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Posts]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6193</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 query that will count the number of <strong>post meta key</strong>.</p>
<p>Let&#8217;s say we need to create a post meta views that will count the number of views per post ID.</p>
<p>First of all, we need to request the data used by fetching the meta key with get_post_meta.</p>
<p>With the example below, we have the post meta key called _post_like_count which will count the number of likes for each WordPress post.</p>
<p>Here&#8217;s the code snippet to inject into your single.php or custom single post type template.</p>

		</div>
	</div>
<div id="ts-enlighterjs-container-6942435" 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-6942435" 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 
$podcast_date = get_post_meta(get_the_ID(), &#039;_post_like_count&#039;, true); 
$count = $podcast_date; 
echo $count; 
if ($count &gt; 1) { 
echo &#039;View(s)&#039;; 
} 
else { 
echo &#039;view&#039;; 
} 
?&gt;</pre></div>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>Feels free to use our <strong>Via Post Meta Key</strong> widget which will automatically sort your posts by <strong>post meta key</strong>.<br />
<a class="more" href="https://themespress.ca/produits/widgets/widget-via-like-post/" target="_blank" rel="noopener">Via Post Meta Key Widget</a></p>

		</div>
	</div>
</div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/count-post-meta-key-by-wordpress-post-id/">Count Post meta key by WordPress Post ID</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/count-post-meta-key-by-wordpress-post-id/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Display the Number of Posts with Draft Status in Admin Menu</title>
		<link>https://themespress.ca/en/display-number-of-draft-posts/</link>
					<comments>https://themespress.ca/en/display-number-of-draft-posts/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 20 Oct 2016 19:31:44 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Users]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6256</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>This tutorial will show you how to add a new function in your WordPress admin which will display the number of posts and post-type with a Draft status.</p>
<p>This function will help WordPress admins to validate posts and post type pending verification with the Draft status.</p>
<p>To accomplish this, we will use the <strong><a href="https://developer.wordpress.org/reference/functions/add_menu_classes/" target="_blank" rel="noopener">add_menu_classes</a></strong> filter.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Display the Number of Posts with Draft Status in Admin Menu</h2><div id="ts-enlighterjs-container-3338842" 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-3338842" 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="">add_filter( &#039;add_menu_classes&#039;, &#039;viavideos_pending_number&#039;); 
function viavideos_pending_number( $menu ) {
    // Changer par le nom de votre Post Type ou post
	$type = &#039;viavideos&#039;;
    // Vous pouvez ici mettre un autre statut
	$status = &#039;draft&#039;;
	// On fait le compte des Posts Ou Post Type
    $num_posts = wp_count_posts( $type, &#039;readable&#039; );
	// On part de 0 en statut draft et on fait le compte
    $pending_count = 0;
    if ( !empty($num_posts-&amp;gt;$status) )
        $pending_count = $num_posts-&amp;gt;$status;

    // build string to match in $menu array
    if ($type == &#039;post&#039;) {
        $menu_str = &#039;edit.php&#039;;
    // support custom post types
    } else {
        $menu_str = &#039;edit.php?post_type=&#039; . $type;
    }

    // On affiche le resultat dans le menu admin concern&eacute;
    foreach( $menu as $menu_key =&amp;gt; $menu_data ) {
        if( $menu_str != $menu_data[2] )
            continue;
        $menu[$menu_key][0] .= &quot; &lt;span class=&quot;update-plugins count-$pending_count&quot;&gt;&lt;span class=&quot;plugin-count&quot;&gt;&quot; . number_format_i18n($pending_count) . &#039;&lt;/span&gt;&lt;/span&gt;&#039;;
    }
    return $menu;
}</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/display-number-of-draft-posts/">Display the Number of Posts with Draft Status in Admin Menu</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/display-number-of-draft-posts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress Query Post by Date</title>
		<link>https://themespress.ca/en/wordpress-query-post-by-date/</link>
					<comments>https://themespress.ca/en/wordpress-query-post-by-date/#respond</comments>
		
		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Wed, 02 Mar 2016 19:28:12 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Posts]]></category>
		<category><![CDATA[Query]]></category>
		<guid isPermaLink="false">https://themespress.ca/?p=6346</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 query that will display Post Type posts from the last 7 days. We will store our arguments inside a variable, $semaine, and we loop it.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >Le Query Post</h2>
	<div class="wpb_text_column wpb_content_element" >
		<div class="wpb_wrapper">
			<p>For this example, our Post Type will be <strong>viavideos</strong>. Replace it with your own Post Type or replace by <strong>post</strong> for your articles.</p>
<p>The <strong>posts_per_page</strong> is set to -1 since we want to do a Query Post for 7 days since we don&#8217;t want it to spread across multiple pages. If you want to paginate it, simply specify the number of results you want per page; for example 5.</p>
<p>We will thus create a query with date_query which will fetch the data from the last 7 days. Notice that we specified the status (post_status) needs to be <strong>publish</strong> and we added orderby Date.</p>

		</div>
	</div>
<h2 style="text-align: left" class="vc_custom_heading vc_do_custom_heading" >WordPress Query Post by Date</h2><div id="ts-enlighterjs-container-9374935" 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-9374935" 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="">&lt;?php 
$semaine = new WP_Query( 
array( 
&#039;post_type&#039;       =&gt; &#039;viavideos&#039;, 
&#039;post_status&#039;     =&gt; &#039;publish&#039;, 
&#039;posts_per_page&#039;  =&gt; -1, 
&#039;orderby&#039;         =&gt; &#039;date&#039;, 
&#039;order&#039;           =&gt; &#039;DESC&#039;, 
&#039;date_query&#039;      =&gt; array( 
	array( 
	&#039;after&#039;       =&gt; &#039;1 week ago&#039; 
	)
) 
)); 
while ( $semaine-&amp;gt;have_posts() ) : $semaine-&amp;gt;the_post(); ?&gt;

&lt;!-- Votre contenu --&gt; 

&lt;?php wp_reset_query(); ?&gt;
&lt;?php endwhile; ?&gt;	</pre></div></div></div></div></div>
</div><p>The post <a href="https://themespress.ca/en/wordpress-query-post-by-date/">WordPress Query Post by Date</a> first appeared on <a href="https://themespress.ca/en/">Themespress</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://themespress.ca/en/wordpress-query-post-by-date/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
