Created
April 5, 2019 04:12
-
-
Save msaari/af8ee093fd4857594ca96baf37cc69d0 to your computer and use it in GitHub Desktop.
PDF icons for GeneratePress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add this to your theme functions.php (or preferably in a custom plugin, because a theme | |
| * update will overwrite the functions.php. | |
| * | |
| * You can also try different locations by replacing the 'generate_before_entry_title' with | |
| * one of the following: | |
| * | |
| * - generate_after_entry_title | |
| * - generate_before_content | |
| * - generate_after_entry_header | |
| */ | |
| add_action( 'generate_before_entry_title', 'rlv_add_mime_icon' ); | |
| function rlv_add_mime_icon() { | |
| $pdf_icon = 'https://cdn4.iconfinder.com/data/icons/file-extensions-1/64/pdfs-128.png'; // Add the URL to your PDF icon here. | |
| if ( is_search() ) { | |
| global $post; | |
| if ( 'application/pdf' === $post->post_mime_type ) { | |
| echo "<img class='file-icon pdf' src='$pdf_icon' alt='PDF' />"; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment