I was recently made aware of a couple of plugin thieves who have taken my code, rebranded it as their own (calling it AmazonPress), redirected the tip to themselves, and made it mandatory rather than optional with no notice to the website owner. In my opinion this constitutes theft from both myself as well as their clients/victims. By not giving credit to me as the original author they are also in violation of the terms of the GPL.
From their site: “We have been online for about 4 years now, we decided to jump in and create an open source plugin for wordpress, it seems there is a need for an amazon plugin that actually works properly, so we decided to go ahead and develop one. Soon to come we will be creating new and awesome plugins.”
If you’re a plugin developer, you better watch out because they might be “creating” your plugin next! If you already use their plugin, you may want to consider another option as they are stealing your commissions without your knowledge or consent. May I recommend the original AmazonFeed?
In coding WordPress plugins and themes, I have often found it necessary to create secondary WordPress loops in the code to show a list of articles or posts on the site that wouldn’t normally appear on the page used to display them. For example, on the homepage of this site, I list articles from three different blog categories in three different lists. The way in which this is accomplished is relatively simple and straightforward.
First, you have to create a new instance of the WP_Query object from WordPress. Due to some complications with the WordPress code, you will need to store the original $wp_query variable in a $temp variable, and override it with your own. You would do this with something like the following code:
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
?>
This constructs a new WP Query object for you which you can then use for subsequent calls in the loop. Once you’ve constructed this object, you will want to define your query variables and run your query.
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = 'cat=5&paged=' . $paged; // Query to pull posts from category ID 5
$wp_query->query($query); // Run the query on the $newposts object.
?>
Now that you have retrieved the necessary posts from your blog, you can begin your secondary loop. The format is slightly different however, in that you should run the have_posts() methods on the new object, rather than as WP functions as is seen below.
<?php
if ($wp_query->have_posts()) :
while ($wp_query->have_posts()) :
$wp_query->the_post();
?>
… regular loop style WP code such as…
<li>
<a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title(); ?>"
><?php the_title(); ?></a>
</li>
… then close the loop.
<?php endwhile; endif; ?>
If necessary you can also add paging controls with the following:
<div class='navigation'>
<div class='alignleft'>
<?php next_posts_link('« Older Entries') ?>
</div>
<div class='alignright'>
<?php previous_posts_link('Newer Entries »') ?>
</div>
</div>
Finally, you need to restore the original $wp_query variable with what you stored in $temp.
<?php $wp_query = null; $wp_query = $temp; ?>
I’d love to hear your feedback on this or if you have any suggestions to improve it. Feel free to comment.