Deal Widget for WordPress MU

by Kishore on February 1, 2010

I created a widget to display ads related to the posts on my deals blog. The purpose of this widget is to display my affiliate links on all the blogs sidebar

image

function kish_get_deals() {
	global $blog_id;
	$current_blog=$blog_id;
	$dealblogid=8;
	switch_to_blog($dealblogid);
	global $post;
	$myposts = get_posts('numberposts=5&orderby=rand');
	?>
<h4 class="widget">Deals - Check it out</h4>
<div style="margin: 5px;background: none transparent scroll repeat 0% 0%;padding: 5px">
	<?php
	foreach($myposts as $post) :
	   setup_postdata($post);
	?>
<div style="margin-top: 3px">
	<li><a href="<?php editable_post_meta($post->ID, " target="_blank">"><?php editable_post_meta($post->ID, "dtitle"); ?></a>

<?php editable_post_meta($post->ID, "ddesc"); ?>

<?php editable_post_meta($post->ID, "durl"); ?><a title="Permanent Link to <?php the_title(); ?>" rel="bookmark" href="<?php the_permalink() ?>"> ¶</a>

</li>
</div>
<?php endforeach;?></div>
<?php switch_to_blog($current_blog);
}

You need to manually add the post_meta fields (custom fields) for those particular blog posts. As I am using the front end editor, I have used the different function, you can change that to get_post_meta function instead. You can add this to your sidebar and if you are using thesis theme, add it to your custom functions.php

  1. Creating a Widget for Displaying Random Category Post : I just created a small hack...
  2. Twitter Plugin for WordPress Updated : I just have updated the new...
  3. Thesis Theme Works With WordPress MU : I recently got thesis theme for...
  4. Pagerank Checking Plugin for WordPress : I have written a simple wordpress...
  5. Delete WordPress Post From Frontend : If you are logged in as...