{"id":4887,"date":"2021-08-15T10:02:15","date_gmt":"2021-08-15T14:02:15","guid":{"rendered":"https:\/\/themespress.ca\/?p=4887"},"modified":"2022-10-01T14:27:52","modified_gmt":"2022-10-01T18:27:52","slug":"posts-published-edited-48-hours","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/posts-published-edited-48-hours\/","title":{"rendered":"Number of Posts Published\/Edited In the last 48 hours"},"content":{"rendered":"<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\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<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>\n<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>\n<p>With our example, the post type is crasyphotosgalleries.<br \/>\nWe 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>\n\n\t\t<\/div>\n\t<\/div>\n<h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >Create a query - Number of posts published\/edited<\/h2>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>With a function we will return the results within a <a href=\"https:\/\/themespress.ca\/categorie\/tutoriels\/\"><strong>WordPress shortcode.<\/strong><\/a><\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-9631504\" 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-9631504\" 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 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\nadd_shortcode( &#039;addocountpost&#039;, &#039;addo_count_posttype_modified&#039; );\nfunction addo_count_posttype_modified(){ \n\t$args = array(\n\t\t&#039;post_type&#039; =&gt; &#039;crasyphotosgalleries&#039;,\n\t\t&#039;date_query&#039; =&gt; array(\n\t\t\t&#039;relation&#039;   =&gt; &#039;OR&#039;,\n\t\t\tarray(\n\t\t\t\t&#039;column&#039;  =&gt; &#039;post_date&#039;,\n\t\t\t\t&#039;after&#039;   =&gt; &#039;-2 days&#039;\n\t\t\t),\n\t\t\tarray(\n\t\t\t\t&#039;column&#039;  =&gt; &#039;post_modified&#039;,\n\t\t\t\t&#039;after&#039;   =&gt; &#039;-2 days&#039;\n\t\t\t)\n\t\t)\n\t);\n\t\/\/ query\n\t$updated = new WP_Query($args);\n\t$totalpost = $updated-&gt;found_posts; \n        return &#039;&lt;div class=&quot;addo40px addocenter&quot;&gt;&#039; . $totalpost . &#039;&lt;\/div&gt;&#039;; \n}<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>You can use the following shortcode in your <strong>content<\/strong>:<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-5153495\" 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-5153495\" 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>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>You can use the following shortcode in your <strong>templates<\/strong>:<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-4399835\" 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-4399835\" 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>\n<\/div>","protected":false},"excerpt":{"rendered":"With this tutorial, we will learn how to create a WP Query which will return the number of posts published or edited during the last 2 days. With this query,<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/posts-published-edited-48-hours\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4892,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[330,322],"class_list":["post-4887","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-posts","tag-query"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=4887"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4887\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4892"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}