WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. 4Gui
    Member
    Posted 2 years ago #

    Hello,

    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.

    Thanks.

    http://wordpress.org/extend/plugins/social-networks-auto-poster-facebook-twitter-g/

  2. Ayman
    Member
    Posted 2 years ago #

    Try using this:

    <?php
      $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
    Member
    Posted 2 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.
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic