Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show Highlight and Share on Posts only
<?php
/**
* Show Highlight and Share on posts only.
*
* @package highlight-and-share
*/
// Hide on all excerpts.
add_filter( 'has_enable_excerpt', '__return_false' );
/**
* Show HAS on posts only.
*
* @param bool $show_on_posts Flag to (true|false) to show on posts/pages.
*
* @return bool Whether to show on posts/pages.
*/
function jeremiahcanuto_show_only_on_posts( $show_on_posts ) {
// Only show on post types.
if ( 'post' === get_post_type() && is_single() ) {
return true;
}
return false;
}
add_filter( 'has_enable_content', 'jeremiahcanuto_show_only_on_posts' ); // Disable or enable main post content.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment