Created
July 20, 2020 12:06
-
-
Save BinaryMoon/0366dbe578d9dd3e0d3be090453d916f to your computer and use it in GitHub Desktop.
Display the full post on search results.
This file contains 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 | |
/** | |
* Plugin Name: Change Mimbo Pro Search Full Post | |
* Plugin URI: https://prothemedesign.com | |
* Description: Display full posts in search results. | |
* Author: Ben Gillbanks | |
* Version: 1.0 | |
* Author URI: https://prothemedesign.com | |
* Text Domain: mimbopro | |
*/ | |
/** | |
* Swap excerpts for full post content on search results. | |
*/ | |
function mimbopro_search_posts( $excerpt, $post ) { | |
if ( is_search() ) { | |
// var_dump( $post ); | |
$excerpt = $post->post_content; | |
} | |
return $excerpt; | |
} | |
add_filter( 'get_the_excerpt', 'mimbopro_search_posts', 9, 2 ); | |
/** | |
* Add custom css to hide thumbnails and ensure images size correctly. | |
*/ | |
function mimbopro_search_css() { | |
if ( ! is_search() ) { | |
return; | |
} | |
?> | |
<style> | |
.cat-excerpt a[rel=bookmark] img { | |
display: none; | |
} | |
.cat-excerpt img { | |
height: auto; | |
} | |
</style> | |
<?php | |
} | |
add_action( 'wp_head', 'mimbopro_search_css' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment