Last active
December 31, 2017 13:04
-
-
Save Dimasmagadan/9031937 to your computer and use it in GitHub Desktop.
«Поделиться» в соцсетях. #WordPress
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 | |
/* подключаем скрипт */ | |
function os_ya_like_script() { | |
wp_enqueue_script( 'yashare', '//yandex.st/share/share.js', null, '1', true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'os_ya_like_script' ); |
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 | |
/* | |
* выводим этот блок в нужном месте через <?php get_template_part('like'); ?> | |
* будет работать только внутри loop | |
*/ | |
?> | |
<div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="small" | |
data-yashareQuickServices="vkontakte,facebook,twitter,odnoklassniki,moimir,gplus" | |
data-yashareTheme="counter" | |
data-yashareLink="<?php the_permalink(); ?>" | |
data-yashareTitle="<?php the_title(); ?>" | |
data-yashareDescription="<?php the_excerpt(); ?>" | |
<?php if(has_post_thumbnail( )){ | |
$thumb=wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium'); | |
?> data-yashareImage="<?php echo $thumb[0]; ?>"<?php | |
} ?> | |
></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment