0
Я хочу добавить текст перед заголовком. Например, "New - the_title()"Как добавить текст перед заголовком социальных кнопок?
$crunchifyTitle = str_replace(' ', '%20', get_the_title());
Так будет отображаться как "New - Planet тройник"
add_action('woocommerce_share', 'crunchify_social_sharing_buttons');
function crunchify_social_sharing_buttons($content) {
if(is_singular() || is_home()){
// Get current page URL
$crunchifyURL = get_permalink();
// Get current page title
$crunchifyTitle = str_replace(' ', '%20', get_the_title());
// Get Post Thumbnail for pinterest
$crunchifyThumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
// Construct sharing URL without using any script
$twitterURL = 'https://twitter.com/intent/tweet?text='.$crunchifyTitle.'&url='.$crunchifyURL.'&via=Crunchify';
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$crunchifyURL;
// Based on popular demand added Pinterest too
$pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$crunchifyURL.'&media='.$crunchifyThumbnail[0].'&description='.$crunchifyTitle;
// Add sharing button at the end of page/page content
$content .= '<div class="crunchify-social">';
$content .= '<h5>SHARE ON</h5> <a class="crunchify-link crunchify-twitter" href="'. $twitterURL .'" target="_blank">Twitter</a>';
$content .= '<a class="crunchify-link crunchify-facebook" href="'.$facebookURL.'" target="_blank">Facebook</a>';
$content .= '<a class="crunchify-link crunchify-pinterest" href="'.$pinterestURL.'" target="_blank">Pin It</a>';
$content .= '</div>';
echo $content;
}
}
Что отображается с кодом? Дайте нам небольшую помощь здесь. –
'$ crunchifyTitle = str_replace ('', '% 20', 'New -'. Get_the_title());' – pavlovich
Как добавить текст, подобный этому «brave & co», он появляется как Brave, the & c0 doesn Не появляется. $ crunchifyTitle = str_replace ('', '% 20', 'Brave & co -'. Get_the_title()); – sisi