Amazon.ca
I’ve just finished integrating the AMM (Amazon Media Manager) Plugin for WordPress. The most obvious place where you will see it is the along the sidebar where I have two random books from my blog’s internal library appearing. Of course, the links have my Amazon Associate id embedded in them so I a (miniscule) cut if you buy through one of my links. The other place you will see this is in posts themselves when I link to a book through the course of conversation.
Here is the code that I used to do all this.
Sidebar
The first thing you need do is create a new AMM Template. This specifies how the results are displayed. My sidebar display format is image on top, the title and author below with the image and title as the link.
<?php <br></br>
function amm_adam_sidebar($amm){ <br></br>
?> <br></br>
<?php for ($x = 0; $x < $amm->totalItems(); $x++ ) : ?> <br></br>
<li> <br></br>
<a href="<?php echo $amm->URL();?>"><img src="<?php echo $amm->autoImage('small');?>" /><br /> <br></br>
<?php echo $amm->title();?></a> by <?php echo $amm->author();?> <br></br>
</li> <br></br>
<br /> <br></br>
<br /> <br></br>
<?php $amm->nextItem(); endfor; ?> <br></br>
<?php <br></br>
} <br></br>
?>
The next thing is to modify the WordPress sidebar template (sidebar.php). What this will do is produce a random (AMM_RANDOM) number of list items (2) from books (AMM_BOOKS) with any rating (AMM_RATING_ALL) as per the formatting in the function amm_adam_sidebar.
<li><h2>Books</h2>
<ul>
<?php amm_getMedia('amm_adam_sidebar', 2, AMM_BOOKS, AMM_RANDOM, AMM_RATING_ALL); ?%gt;
</ul>
</li>
Posts
Again, you need an AMM Template to display things as you want them to be embedded in your posts.
<?php
function amm_adam_inline($amm){
?>
<a href="<?php echo $amm->URL();?>"><?php echo $amm->title();?></a> by <?php echo $amm->author();?>
<?php
}
?>
Inside the post itself, when I want to include a book reference, I do the following. The number there is the number associated with the entry in your AMM database which you configure through the console.
<!--amm_getMediaID('amm_adam_inline',2)-->
Finally, to enable your output in a post to actually appear, you have to add a WP Custom Tag of amm with a value of enabled. Took me a good half an hour to stumble upon that section of the docs.
Amazon vs. Indigo
I had originally wanted to have all the books linked via Indigo instead of Amazon, but when I went to register they wanted my SIN (the Canadian equivilant of the Social Security number) over a non-secure browser session. Thanks, but no thanks.