Skip to content

Instantly share code, notes, and snippets.

@BinaryMoon
Created July 20, 2020 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BinaryMoon/0366dbe578d9dd3e0d3be090453d916f to your computer and use it in GitHub Desktop.
Save BinaryMoon/0366dbe578d9dd3e0d3be090453d916f to your computer and use it in GitHub Desktop.
Display the full post on search results.
<?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