NextScripts: Social Networks Auto-Poster
Facebook Conditional Thumbnail (3 posts)

  1. 4Gui
    Posted 3 years ago #


    first of all thanks for this great plugin!
    I'm trying to implement a conditional thumbnail based on category but all my attempts failed.
    This was my last try:

    if ( in_category( 'X' )) {
    $imgURL  = 'Path/X.jpg'; 
    } else {
    if (trim($imgURL)!='') $mssg['picture'] = $imgURL;

    Can you please give me some hints.



  2. Ayman
    Posted 3 years ago #

    Try using this:

      $src = '<?php bloginfo('template_directory'); ?>/images/default-category-image.jpg" alt="<?php the_title(); ?>'
          if (is_category('XXXX')) {
          the_post_thumbnail('thumbnail', array('$src'));
  3. 4Gui
    Posted 3 years ago #

    Thanks for your answer but unfortunately it doesn't help me.
    I got this code in header which work great in Facebook developers debug, share, like, etc...but not with this plugin cause he always grab the featured image thumbnail not the og:image?

    <?php if ( in_category( 'x' )) { ?>
    					<meta property="og:image" content="<?php $post_thumbnail = bloginfo('template_directory') . '/images/x.png'; echo $post_thumbnail; ?>" />
                        <link rel="image_src" href="<?php $post_thumbnail = bloginfo('template_directory') . '/images/x.png'; echo $post_thumbnail; ?>" / >
    				<?php } else { ?>
                <meta property="og:image" content="<?php $post_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'large'); echo $post_thumbnail[0]; ?>" />
                 <link rel="image_src" href="<?php $post_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'large'); echo $post_thumbnail[0]; ?>" / >
                <?php } ?>

    I believe the changes have to be done in how the plugin grabs the thumbnail and i tried it but again without success.
    Help please.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • NextScripts: Social Networks Auto-Poster
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic