Created
July 11, 2022 13:37
-
-
Save dlxsnippets/8e4561dad5625e0dce47e13dad90aabe to your computer and use it in GitHub Desktop.
Show Highlight and Share on Posts only
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 | |
/** | |
* 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