WordPress.org

Ready to get started?Download WordPress

Forums

Issues with open graph (url and title) (4 posts)

  1. gabriellacrafa
    Member
    Posted 1 year ago #

    Hi,
    in my site http://www.tvserial.it, to integrate opengraph first I triyed to install a plugin for opengraph integration but doesn't work andh than I've modifyed the code as you can see but I've followed the instructions in variuos sites, including open graph directly in the code.

    Now I guess a problea in the post, so the error is this: https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.tvserial.it%2Fgirls-promo-della-seconda-serie%2F

    Altought when I try to share a post I can't see the image and the description, only the title appears.

    I've the same problems with comments and with like (when someone like a post this doesn't show in FB)..

    This is the code I've inserter in my site. Can you help to find the problem please?

    Thanks

    In HEAD I've inserted this:

    <?php if (have_posts()):while(have_posts()):the_post(); endwhile; endif;?>
    
    <!-- Valori iniziali -->
    <meta property="fb:app_id" content="342582249174051">
    <!-- Se la pagina è un articolo -->
    <?php if (is_single()) { ?>
    <meta property="og:url" content="<?php the_permalink() ?>">
    <meta property="og:title" content="<?php single_post_title(''); ?>">
    <meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>">
    <meta property="og:image" content="<?php if (function_exists('catch_that_image')) {echo catch_that_image(); }?>">
    <!-- Se è una qualunque altra pagina -->
    <?php } else { ?>
    <meta property="og:site_name" content="<?php bloginfo('name'); ?>">
    <meta property="og:description" content="<?php bloginfo('description'); ?>">
    <meta property="og:image" content="http://www.tvserial.it/wp-content/themes/Lucid/images/tvserial.png"> <?php } ?>

    In BODY I've inserted this:

    <div id="fb-root"></div>
    <script>
    window.fbAsyncInit = function() {
    FB.init({appId: '342582249174051', status: true, cookie: true,
    xfbml: true});
    };
    (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
    }());
    </script>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum's parser.]

  2. esmi
    Forum Moderator
    Posted 1 year ago #

  3. gabriellacrafa
    Member
    Posted 1 year ago #

    Hi,
    sorry but I don't know what you mean and I've no javascript skill. I suppose there is a problem with this part of code. Is it correct?
    Thanks

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    Yep. You need to look at how to correctly add a javascript file to your theme/site.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags