Home / attachment / Display total number of PDF files in your media library
  • How to Display total number of PDF files in your media library

    display-total-number-of-pdf-files-in-your-media-library

    Adding this snippet to the functions.php of your wordpress theme will return the total number of PDF files within your media library.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    function pdf_count(){
    	$query_pdf_args = array(
    		'post_type' => 'attachment',
    		'post_mime_type' =>'application/pdf',
    		'post_status' => 'inherit',
    		'posts_per_page' => -1,
    		);
    	$query_pdf = new WP_Query( $query_pdf_args );
    	echo $query_pdf->post_count;
    }
    
    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?
         pdf_count();
    ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    posts_per_page, query, wp,