{"id":4189,"date":"2021-02-26T11:16:47","date_gmt":"2021-02-26T16:16:47","guid":{"rendered":"https:\/\/themespress.ca\/?p=4189"},"modified":"2021-07-07T09:43:36","modified_gmt":"2021-07-07T13:43:36","slug":"get-post-page-quantity-by-user-role","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/","title":{"rendered":"Get Post\/Page quantity by user role"},"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 create new WordPress functions which will get the quantity of posts or post types by user role.<br \/>\nIn 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>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-1135178\" 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-1135178\" 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 ***********************************\/\n\nfunction themespress_role_partenaire() {  \n    \/\/add the new user role\n    add_role(\n        &#039;chroniqueur&#039;,\n        &#039;Chroniqueur&#039;,\n        array(\n            &#039;read&#039;         =&gt; true,\n            &#039;delete_posts&#039; =&gt; false\n        )\n    );\n \n}\nadd_action(&#039;admin_init&#039;, &#039;themespress_role_partenaire&#039;);<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<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>\n<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>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-3305350\" 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-3305350\" 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){\n\/\/ Change here the user role\n       $user_query = new WP_User_Query( array( &#039;role&#039; =&gt; &#039;chroniqueur&#039; ) );\n\t\/\/ Get the total number of users for the current query. I use (int) only for sanitize.\n\t$users_count = (int) $user_query-&gt;get_total();\n\t\/\/ Echo a string and the value\n\treturn $users_count;\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>Now we will create a shortcode that will return the value of the function above. For example our shortcode will be: [chroniqueurchahutcount]<\/p>\n<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>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-6493264\" 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-6493264\" 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 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\nfunction shortcode_chroniqueurs_count_chahut(){\n$user_ID = get_current_user_id(); \nreturn count_chahuts_by_author($user_ID, &#039;chahuts&#039;);\n}\nadd_shortcode(&#039;chroniqueurchahutcount&#039;, &#039;shortcode_chroniqueurs_count_chahut&#039;);<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<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>\n<p>Be careful as this tutorial will generate the result for a user connected with their user_id (current_user).<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4238,"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-4189","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-posts","tag-query"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Share the post &quot;Get Post\/Page quantity by user role&quot; Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Daniel\"\/>\n\t<meta name=\"google-site-verification\" content=\"t6BGEKVeq0mBMvotb-TgZMJCdlDLuU-VkrnMjlExL5M\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Themespress - Des tutoriels et ressources WordPress\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Get Post\/Page quantity by user role - Themespress\" \/>\n\t\t<meta property=\"og:description\" content=\"Share the post &quot;Get Post\/Page quantity by user role&quot; Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2021-02-26T16:16:47-05:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2021-07-07T13:43:36-04:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Get Post\/Page quantity by user role - Themespress\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Share the post &quot;Get Post\/Page quantity by user role&quot; Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#blogposting\",\"name\":\"Get Post\\\/Page quantity by user role - Themespress\",\"headline\":\"Get Post\\\/Page quantity by user role\",\"author\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/author\\\/daniel\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/themespress.ca\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/Obtenir-le-nombre-darticles-type-darticles-par-role-utilisateur.png\",\"width\":1920,\"height\":1006,\"caption\":\"Obtenir le nombre d'articles \\\/ type d'articles par r\\u00f4le utilisateur\"},\"datePublished\":\"2021-02-26T11:16:47-05:00\",\"dateModified\":\"2021-07-07T09:43:36-04:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#webpage\"},\"articleSection\":\"Tutorials, Posts, Query, Optional\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#listItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/themespress.ca\\\/en\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/categorie\\\/tutorials\\\/#listItem\",\"name\":\"Tutorials\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/categorie\\\/tutorials\\\/#listItem\",\"position\":2,\"name\":\"Tutorials\",\"item\":\"https:\\\/\\\/themespress.ca\\\/en\\\/categorie\\\/tutorials\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#listItem\",\"name\":\"Get Post\\\/Page quantity by user role\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#listItem\",\"name\":\"Accueil\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#listItem\",\"position\":3,\"name\":\"Get Post\\\/Page quantity by user role\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/categorie\\\/tutorials\\\/#listItem\",\"name\":\"Tutorials\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#organization\",\"name\":\"Themespress\",\"description\":\"Des tutoriels et ressources WordPress\",\"url\":\"https:\\\/\\\/themespress.ca\\\/en\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/author\\\/daniel\\\/#author\",\"url\":\"https:\\\/\\\/themespress.ca\\\/en\\\/author\\\/daniel\\\/\",\"name\":\"Daniel\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93cd2188e40b3289d305e88acb676eb8b84078e50e06f4eb38a0152903b34c9d?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Daniel\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#webpage\",\"url\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/\",\"name\":\"Get Post\\\/Page quantity by user role - Themespress\",\"description\":\"Share the post \\\"Get Post\\\/Page quantity by user role\\\" Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/author\\\/daniel\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/author\\\/daniel\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/themespress.ca\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/Obtenir-le-nombre-darticles-type-darticles-par-role-utilisateur.png\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#mainImage\",\"width\":1920,\"height\":1006,\"caption\":\"Obtenir le nombre d'articles \\\/ type d'articles par r\\u00f4le utilisateur\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/get-post-page-quantity-by-user-role\\\/#mainImage\"},\"datePublished\":\"2021-02-26T11:16:47-05:00\",\"dateModified\":\"2021-07-07T09:43:36-04:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/themespress.ca\\\/en\\\/\",\"name\":\"Themespress\",\"description\":\"Des tutoriels et ressources WordPress\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/themespress.ca\\\/en\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Get Post\/Page quantity by user role - Themespress","description":"Share the post \"Get Post\/Page quantity by user role\" Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a","canonical_url":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"google-site-verification":"t6BGEKVeq0mBMvotb-TgZMJCdlDLuU-VkrnMjlExL5M","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#blogposting","name":"Get Post\/Page quantity by user role - Themespress","headline":"Get Post\/Page quantity by user role","author":{"@id":"https:\/\/themespress.ca\/en\/author\/daniel\/#author"},"publisher":{"@id":"https:\/\/themespress.ca\/en\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/themespress.ca\/wp-content\/uploads\/2021\/02\/Obtenir-le-nombre-darticles-type-darticles-par-role-utilisateur.png","width":1920,"height":1006,"caption":"Obtenir le nombre d'articles \/ type d'articles par r\u00f4le utilisateur"},"datePublished":"2021-02-26T11:16:47-05:00","dateModified":"2021-07-07T09:43:36-04:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#webpage"},"isPartOf":{"@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#webpage"},"articleSection":"Tutorials, Posts, Query, Optional"},{"@type":"BreadcrumbList","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/#listItem","position":1,"name":"Accueil","item":"https:\/\/themespress.ca\/en\/","nextItem":{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/categorie\/tutorials\/#listItem","name":"Tutorials"}},{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/categorie\/tutorials\/#listItem","position":2,"name":"Tutorials","item":"https:\/\/themespress.ca\/en\/categorie\/tutorials\/","nextItem":{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#listItem","name":"Get Post\/Page quantity by user role"},"previousItem":{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/#listItem","name":"Accueil"}},{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#listItem","position":3,"name":"Get Post\/Page quantity by user role","previousItem":{"@type":"ListItem","@id":"https:\/\/themespress.ca\/en\/categorie\/tutorials\/#listItem","name":"Tutorials"}}]},{"@type":"Organization","@id":"https:\/\/themespress.ca\/en\/#organization","name":"Themespress","description":"Des tutoriels et ressources WordPress","url":"https:\/\/themespress.ca\/en\/"},{"@type":"Person","@id":"https:\/\/themespress.ca\/en\/author\/daniel\/#author","url":"https:\/\/themespress.ca\/en\/author\/daniel\/","name":"Daniel","image":{"@type":"ImageObject","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/93cd2188e40b3289d305e88acb676eb8b84078e50e06f4eb38a0152903b34c9d?s=96&d=mm&r=g","width":96,"height":96,"caption":"Daniel"}},{"@type":"WebPage","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#webpage","url":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/","name":"Get Post\/Page quantity by user role - Themespress","description":"Share the post \"Get Post\/Page quantity by user role\" Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/themespress.ca\/en\/#website"},"breadcrumb":{"@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#breadcrumblist"},"author":{"@id":"https:\/\/themespress.ca\/en\/author\/daniel\/#author"},"creator":{"@id":"https:\/\/themespress.ca\/en\/author\/daniel\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/themespress.ca\/wp-content\/uploads\/2021\/02\/Obtenir-le-nombre-darticles-type-darticles-par-role-utilisateur.png","@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#mainImage","width":1920,"height":1006,"caption":"Obtenir le nombre d'articles \/ type d'articles par r\u00f4le utilisateur"},"primaryImageOfPage":{"@id":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/#mainImage"},"datePublished":"2021-02-26T11:16:47-05:00","dateModified":"2021-07-07T09:43:36-04:00"},{"@type":"WebSite","@id":"https:\/\/themespress.ca\/en\/#website","url":"https:\/\/themespress.ca\/en\/","name":"Themespress","description":"Des tutoriels et ressources WordPress","inLanguage":"en-US","publisher":{"@id":"https:\/\/themespress.ca\/en\/#organization"}}]},"og:locale":"en_US","og:site_name":"Themespress - Des tutoriels et ressources WordPress","og:type":"article","og:title":"Get Post\/Page quantity by user role - Themespress","og:description":"Share the post &quot;Get Post\/Page quantity by user role&quot; Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a","og:url":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/","article:published_time":"2021-02-26T16:16:47-05:00","article:modified_time":"2021-07-07T13:43:36-04:00","twitter:card":"summary","twitter:title":"Get Post\/Page quantity by user role - Themespress","twitter:description":"Share the post &quot;Get Post\/Page quantity by user role&quot; Facebook LinkedIn Twitter Partager... E-mail Ajouter aux favoris Bluesky With this tutorial, we will create new WordPress functions which will get the quantity of posts or post types by user role. In the example below, the role will be chroniqueur. If we want to add a"},"aioseo_meta_data":{"post_id":"4189","title":null,"description":null,"keywords":[],"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[],"defaultGraph":"Article","defaultPostTypeGraph":""},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":{"locations":{"business":{"name":"","businessType":"","image":"","areaServed":"","urls":{"website":"","aboutPage":"","contactPage":""},"address":{"streetLine1":"","streetLine2":"","zipCode":"","city":"","state":"","country":"","addressFormat":"#streetLineOne\\n#streetLineTwo\\n#city, #state #zipCode"},"contact":{"email":"","phone":"","phoneFormatted":"","fax":"","faxFormatted":""},"ids":{"vat":"","tax":"","chamberOfCommerce":""},"payment":{"priceRange":"","currenciesAccepted":"","methods":""}}},"openingHours":{"useDefaults":true,"show":false,"alwaysOpen":false,"use24hFormat":false,"timezone":"","labels":{"closed":"","alwaysOpen":""},"days":{"monday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"tuesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"wednesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"thursday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"friday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"saturday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"sunday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"}},"closedLabel":"","open24h":false,"open24hLabel":"","open247":false,"twoSets":false,"hours":[]},"businessInfo":{"name":"","urls":{"website":"","aboutPage":"","contactPage":""},"address":{"line1":"","line2":"","zip":"","city":"","state":"","country":""},"contact":{"email":"","phone":"","fax":""},"ids":{"vatID":"","taxID":"","chamberID":""},"payment":{"priceIndication":"","currenciesAccepted":"","methodsAccepted":""},"areaServed":""}},"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-03-06 14:15:47","updated":"2025-06-07 20:39:06","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/themespress.ca\/en\/\" title=\"Accueil\">Accueil<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/themespress.ca\/en\/categorie\/tutorials\/\" title=\"Tutorials\">Tutorials<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGet Post\/Page quantity by user role\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Accueil","link":"https:\/\/themespress.ca\/en\/"},{"label":"Tutorials","link":"https:\/\/themespress.ca\/en\/categorie\/tutorials\/"},{"label":"Get Post\/Page quantity by user role","link":"https:\/\/themespress.ca\/en\/get-post-page-quantity-by-user-role\/"}],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4189","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=4189"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4189\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4238"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}