• If you’ve got the following code in the front page – something to display an excerpt of the latest post in a particular category – and want to put a “social button” for Digg, StumbleUpon, Twitter, Facebook and Deli.cio.us, how would you do it?

    Is there any way to automate this? Or do you need to write out custom PHP scripts? I know this might be much to ask for, but would anyone care to post a code snippet or two for this?

    <?php while($videos->have_posts()) { $videos->the_post(); ?>
    		<?php if($video_count == 1) { ?>
    		<div class="latest">
    			<?php
    			$content = get_the_content();
    			$content = preg_replace('/width="(.*?)"/', 'width="274"', $content);
    			$content = preg_replace('/height="(.*?)"/', 'height="225"', $content);
    			$video_match = preg_match_all('/<object (.*)><\/object>/', $content, $video_matches);
    			echo $video_matches[0][0];
    			?>
    			<h3 class="headline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    			<?php $excerpt = trim(get_the_excerpt()); ?>
    			<?php if($excerpt != '') { ?>
    		 		<p class="entry"><?php echo substr($excerpt, 0, 90); ?> &hellip; <a href="<?php the_permalink(); ?>" class="more">more</a></p>
    			<?php } ?>
    			<?php $testimonial = get_post_meta($post->ID , 'testimonial', true); ?>
    	 	</div>
    		<?php } else if ($video_count < 7) {
    			$tv_list .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
    		} ?>
    		<?php $video_count++;
    		}?>
    		<div class="related">
    		<?php if ($testimonial) {
    			echo '<blockquote><p>' . $testimonial . '</p></blockquote>';
    		} ?>
    
    			<?php
    			if ($tv_list != '') {
    				echo '<div class="archive"><h4>Previous TV Shows</h4>';
    				echo '<ul>' . $tv_list . '</ul>';
    				echo '</div><!-- /.archive -->';
    			}
    			?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to add dynamic share buttons on Front Page’ is closed to new replies.