tigaman webdesign sopron
2022..0728.

Facebook meta tag hozzáadása a wordpress fejrészéhez – kód részlet vagy wordpress plugin

Ez a kódrészlet hozzáadja a Facebook Open Graph meta tageket a fejléchez, és automatikusan kitölti őket, így segítve a Facebook oldalakon vagy csoportokban való megosztást.

Facebook meta tag hozzáadása a WordPress fejlécéhez plugin nélkül

 

Kattints a kódra a vágólapra másoláshoz


<?php add_action('wp_head', 'twd_facebook_meta');function twd_facebook_meta(){?>
<meta property=”og:url” content=”<?php the_permalink() ?>”/>
<meta property=”og:title” content=”<?php single_post_title(”); ?>” />
<meta property=”og:description” content=”<?php if (have_posts() && is_single() OR is_page()):while(have_posts()):the_post();$out_excerpt = str_replace(array(“\r\n”, “\r”, “\n”), “”, get_the_excerpt());echo apply_filters('the_excerpt_rss', $out_excerpt);
endwhile; endif; ?>” />
<meta property=”og:type” content=”article” />
<meta property=”og:image” content=”<?php if ( has_post_thumbnail() ) {the_post_thumbnail_url();} else { ?><?php bloginfo('template_directory'); ?>/screenshot.jpg<?php } ?>” />
<?php };?>

letölthető innen: https://www.tigaman.com/add-facebook-meta-tag-to-the-header-with-code-snippet-or-without-wordpress-plugin/


Ajánlatkérés
AjánlatkérésMennyibe fog kerülni?