Open Graph Pro
Grabbing sidebar images, not Featured Image for Facebook (2 posts)

  1. aaron1728
    Posted 3 years ago #

    I tried to put the following on Facebook
    and the 3 thumbnail images it is suggesting aren't of Featured Image. All are from the sidebar. One of them is even a sidebar image that was removed a few days ago.

    Please advise.


  2. Morocco English
    Posted 3 years ago #

    do u still have the problem .
    you can add this code to your header :

    <?php if (have_posts()):while(have_posts()):the_post(); endwhile; endif;?>
    <!-- if page is content page -->
    <?php if (is_single()) { ?>
    <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:type" content="article" />
    <meta property="og:image" content="<?php if (function_exists('wp_get_attachment_thumb_url')) {echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID)); }?>" />   
    <!-- if page is others -->
    <?php } else { ?>
    <meta property="og:site_name" content="MoroccoEnglish" />
    <meta property="og:type" content="website" />
    <meta property="og:image" content="a-default-thumbnail.jpg" />
     <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Open Graph Pro
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic