Title: How to add dynamic share buttons on Front Page
Last modified: August 19, 2016

---

# How to add dynamic share buttons on Front Page

 *  [splatt_](https://wordpress.org/support/users/splatt_/)
 * (@splatt_)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/help-with-code-anyone/)
 * 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)

 *  Thread Starter [splatt_](https://wordpress.org/support/users/splatt_/)
 * (@splatt_)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/help-with-code-anyone/#post-1252544)
 * just a little bump

Viewing 1 replies (of 1 total)

The topic ‘How to add dynamic share buttons on Front Page’ is closed to new replies.

## Tags

 * [buttons](https://wordpress.org/support/topic-tag/buttons/)
 * [front page](https://wordpress.org/support/topic-tag/front-page/)
 * [php code](https://wordpress.org/support/topic-tag/php-code/)

 * 1 reply
 * 1 participant
 * Last reply from: [splatt_](https://wordpress.org/support/users/splatt_/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/help-with-code-anyone/#post-1252544)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
