• Feb
  • 18

Instantly boost your blog’s visibility with cross-promotion

Do you have more than one website? Or a friend with a website? Wouldn't it be great to easily be able to promote your Wordpress blog on those other sites? Maybe you'd like to:

  • Display an up-to-the-minute listing of your latest posts?
  • Or show a listing of your most popular or most commented posts?
  • Maybe show some live stats from your Wordpress blog on another of your sites?
  • Or, what about displaying some of your Wordpress site's ads on your non-Wordpress website?

How can we easily achieve this:

Cross promote Wordpress blog

Stage 1 - install the Custom Page plugin

First you should download and install my 'Custom Slug, Custom Page' plugin from this page:

The plugin allows you to create a page with a custom slug, with whatever content you like and - importantly - with full access to the Wordpress functions and plugin architecture.

Stage 2 - create a Custom page with the content to promote

Let's make a custom page that displays a list of the 3 most recent posts on my blog. So, once you've installed the plugin, click on Options, then Custom Page, then New Page:

For the slug, let's enter "recent-posts":

Now, for the content. First let's enter some code to create the recent posts lists. If you're not a coder, don't worry, just paste this in (you can't damage anything). Include the starting <? and final ?>.

Plugin Name: Recent Posts
Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/

function mdv_recent_posts($no_posts = 3, $before = '<li>', $after = '</li>', $hide_pass_post = true, $skip_posts = 0, $show_excerpts = false) {
global $wpdb;
$time_difference = get_settings('gmt_offset');
$now = gmdate("Y-m-d H:i:s",time());
$request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' ";
if($hide_pass_post) $request .= "AND post_password ='' ";
$request .= "AND post_date_gmt <'$now' ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
$posts = $wpdb->get_results($request);
$output = '';
if($posts) {
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
$output .= $before . '<a href="' . $permalink . '" rel="nofollow" target="_blank" title="Permanent Link: ' . htmlspecialchars($post_title, ENT_COMPAT) . '">' . htmlspecialchars($post_title) . '</a>';
if($show_excerpts) {
$post_excerpt = stripslashes($post->post_excerpt);
$output.= '<br />' . $post_excerpt;
$output .= $after;
} else {
$output .= $before . "None found" . $after;
return $output;

Thanks to http://mtdewvirus.com/code/wordpress-plugins/ for the code. OK, so now all we need is the HTML for the document, and some CSS to style our bulleted list. (Just paste this into the content box, below the code you've just pasted in)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body {

div#container_drp h4 {
margin:3px 0 3px 0;

div#container_drp ul {
margin: 10px 0 10px 0px;
border:1px solid #ccc;

div#container_drp li  {
padding-left: 15px;
background-position:0px 1px;

div#container_drp {
border:1px solid #ccc;

You can change these styles as you see fit, or just leave it as it is. You should change the image for the bullet to one of your own. Finally we, just need to add the body of the document, and to close the HTML tags:

<div id='container_drp'>
<h4>What's new on <a href='<? echo get_bloginfo('url'); ?>' target=_blank><? echo get_bloginfo('name'); ?>?</a></h4>
<? echo mdv_recent_posts() ?>

Submit the page, and then click on Manage. Your new page should be available to manage, and you will see a link to it. It will be like this: http://aciddrop.com/recent-posts (but with your domain instead of aciddrop.com). Click the link to view the page. You should get something like this:

Your new custom page

Ok, great. Now what?

The final stage is to get this page to display on your other blog or site. The easiest way to do this is through an iframe. This is an HTML tag that you can use to display a page within another page. So, let say we want to display the info an other Wordpress blog, in the sidebar.

Open up sidebar.php of the theme you use (or whichever file displays the sidebar), and paste in this code where you would like the info to be displayed:

<iframe src="http://aciddrop.com/recent-posts" width="156" height="250" scrolling="no" frameborder="0" allowtransparency="true" background-color="transparent"></iframe>

Of course, you should change aciddrop.com to your own domain. You may need to adjust the width and height depending on the info that you are displaying. That's it!


Just have a look in the right hand bar of this site, and you will see I'm using this technique to display recent posts from both this blog, and another one.

Other uses

The technique isn't restricted to just displaying recent posts. Any time you would like to easily display info from your blog on another site you can use it. Please let me know if you come up with some other ingenious uses.

As usual, please let me know of any bugs/feedback/comments.

Want to hear of other ingenious uses for the plugin? Or be the first to try out my upcoming PHP Speedy Wordpress plugin? Then subscribe to my feed!

Related posts

Posted by admin in php, tutorials, wordpress

  • Feb
  • 19


Here are some thoughts from a non-tech Japanese guy.

Would you be able to use this as a sidebar tool to display on the blog for things such as "Visitors to this page also liked" or "Popular pages today" ? FEEDJIT provides this free service but with very limited flexibitiy in design.

As for "Visitors to this page also liked", there is a WP plugin "Where did they go from here?". But it stopped working on my blog for some reason.

Sorry for my ingnorance but really like to have these functions on my blog.
I'm also looking forward for your PHP Speedy plugin.

Thanks for your great work!

  • Feb
  • 19

Hi yoichi,

Yes, you can use it to display anything you want. In the example I used recent posts, but you have full design and code flexibility.

For the "visitors to the page also liked" plugin, this isn't really a cross-promotion technique, but an internal promotion technique. As such, it's not really what the plugin and tutorial is intended for. It would be tricky to do via Iframe.

Popular pages is more the sort of thing it's intended for. You could definitely integrate it with a Wordpress stats plugin to do that. I don't use one myself, so I can't comment, but I can look into it for you, and make it the subject of another blog post.

  • Feb
  • 20

Thanks Leon for your quick response.
That would be great if you could do that when you can find the time.


  • Feb
  • 21

Can we use

instead of iframe tag


  • Feb
  • 21

tony - I think WP stripped your tag. enter it without the < and >

  • Feb
  • 22

It would be nice to hide iframe tag
and use PHP code instead

echo $content;

But it does not work.

  • Feb
  • 28

tony - because of the redirect, file_get_contents won't work. You can use curl though. This should work:

function get_page($url) {
    $ch = curl_init();   

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
    //Return results as string
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    //Set timeout value and auto referer
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 15);

    $page = curl_exec($ch);
    return $page;


echo get_page("http://aciddrop.com/recent-posts");

Comments are closed