Skip to content

Instantly share code, notes, and snippets.

@pickplugins
Created May 7, 2023 04:18
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 pickplugins/3159e7297c93757b1ada3a7221ff60af to your computer and use it in GitHub Desktop.
Save pickplugins/3159e7297c93757b1ada3a7221ff60af to your computer and use it in GitHub Desktop.
add_filter('post_grid_share_buttons', 'post_grid_share_buttons_custom', 90, 2);
function post_grid_share_buttons_custom($share_button_html, $args)
{
$element = isset($args['element']) ? $args['element'] : array();
$post_id = isset($args['post_id']) ? $args['post_id'] : '';
$post_title = get_the_title($post_id);
$post_link = get_permalink($post_id);
$link_target = isset($element['link_target']) ? $element['link_target'] : '';
$share_button_html .= '
<span class="fb">
<a target="' . $link_target . '" href="https://www.facebook.com/sharer/sharer.php?u=' . $post_link . '"><i class="fab fa-facebook-square"></i></a>
</span>
<span class="twitter">
<a target="' . $link_target . '" href="https://twitter.com/intent/tweet?url=' . $post_link . '&text=' . $post_title . '"><i class="fab fa-twitter-square"></i></a>
</span>';
return $share_button_html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment