Very short snippet: ottenere il numero di Post, Page e Attachment

Come molti di voi sanno bene, la tabella wp_posts di WordPress è utilizzata per memorizzare Post, Pagine e allegati. La tipologia dell’elemento memorizzato è determinata dal campo post_type. Con la select proposta qui sotto, è possibile “contare” singolarmente le varie tipologie di elementi memrizzate in wp_posts.

1
SELECT COUNT(*), post_type FROM `wp_posts` GROUP BY post_type

Ottenendo ad esempio:

1
2
3
4
5
count(*) | post_type
---------+------------
20       | attachment
5        | page
35       | post

Non ci sono commenti per questo Post

Lascia un commento

TAG XHTML PERMESSI: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERIMENTO CODICE:
<pre></pre> // blocco generico
                   <code></code> // blocco generico
                   [cc_actionscript][/cc_actionscript] // Actionscript
                   [cc_actionscript3][/cc_actionscript3] // Actionscript 3
                   [cc_css][/cc_css] // CSS Style Sheet
                   [cc_html][/cc_html] // HTML
                   [cc_js][/cc_js] // Javascript
                   [cc_objc][/cc_objc] // Objective-C
                   [cc_php][/cc_objc] // PHP
                   [cc_sql][/cc_sql] // SQL