Skip to content

Instantly share code, notes, and snippets.

@dlxsnippets
Created July 11, 2022 13:37
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 dlxsnippets/8e4561dad5625e0dce47e13dad90aabe to your computer and use it in GitHub Desktop.
Save dlxsnippets/8e4561dad5625e0dce47e13dad90aabe to your computer and use it in GitHub Desktop.
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