Archive for January, 2006

Multiple Loops in Wordpress

I wanted to run the wordpress loop on my php page more than once, & I don’t know if I’m the only person, but I found the offical multiple look example hard to swallow.

Google found is nima’s how to which was useful, but I wanted to take it further; the problem was I wanted a function.

This is what I came up with:

<?php
require(‘path_to_wordpress/wp-blog-header.php’);
?>

<?php
function show_posts_from_cat($MYCAT){

?>

<ul>
<?php if (have_posts()) : ?>

<?php $my_query = new WP_Query(“category_name=$MYCAT”); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li>

<span class=”my-post-title”>
<span id=”post-<?php the_ID(); ?>”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></a></span>
<!–
<?php trackback_rdf(); ?>
–>
</span>
<small><?php the_time(‘jS F Y’) ?> <!– by <?php the_author() ?> –></small>
</li>

<?php endwhile; ?>

<?php else : ?>

<h2 class=”center”>Not Found</h2>
<p class=”center”><?php _e(“looks like there aren’t any related posts.”); ?></p>

<?php endif; ?>

</ul>

<?php
}
?>

So here’s what I found, if you just run the wordpress loop twice, the second time you run it, it’ll fail :s so my function creates a new object each time you run the loop. The object is then used to display the results, the benefit being ,each time you call the function it over-writes the object with the new results, allowing you to call the function as many times as you like, and generating fresh results every time :D

function usage: show_posts_from_cat(“Category_name”);

Good luck, let me know if you have ant problems.

Google Adsense code (javascript) in wordpress pages / posts

For ages I could not work out why google ad’s included within a wordpress page didn’t work (in fact this applies to a post too). When google support pointed out that there was <br/> ’s in my code the penny finally dropped.

So here’s the deal, I pasted the following code into my page: (In the wordpress dashboard)

firefox ad
<!– FireFox Referral –>
<script type=”text/javascript”>
<!–
google_ad_client = “pub-6732086233580907″;
google_ad_width = 180;google_ad_height = 60;
google_ad_format = “180×60_as_rimg”;
google_cpa_choice = “CAAQyaj8zwEaCIwcWMzeycafKMu293M”;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>

adsense ad
<!– Adsense Referral–>
<script type=”text/javascript”>
<!–
google_ad_client = “pub-6732086233580907″;
google_ad_width = 180;
google_ad_height = 60;
google_ad_format = “180×60_as_rimg”;
google_cpa_choice = “CAAQ__qy0gEaCP_s0gMhUOtXKL3D93M”;
//–>
</script>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>

and look what happens…..
firefox ad


adsense ad


Wordpress adds page formatting to the java script that is posted, so if you look at the source, what you actually get is…

<!– FireFox Referal –><br />
<script type=”text/javascript”><br />
<!– <br />
google_ad_client = “pub-6732086233580907″;<br />
google_ad_width = 180;google_ad_height = 60;<br />
google_ad_format = “180×60_as_rimg”;<br />
google_cpa_choice = “CAAQyaj8zwEaCIwcWMzeycafKMu293M”; <br />
//–><br />
</script><br />
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script><br />

… DOH !!!!!!

2006 – Year of calcylator ?

So It’s the new year, and I wanted to post an update about what’s happening over at calcylator.com. I guess it’s been nearly a month since there has been any visible activity, and I’d like to explain the reasons why.

The site was launched in November, and at the time I thought it’d be ready for use by x-mas ebay sellers; after a couple of weeks hammering by my faithful testers I soon found the finish line was further away then I thought :( The application has 2 major hurdles to overcome:

  1. Streamlining the user experience
  2. Small target audience (related to fees)

Calcylator started like most applications, to solve a problem for one person, I then wanted to share it with the world. Where as the application fitted this one person, other people found they were working too hard – the same goes for the fees issue – the database fees don’t allow for foreign currency or power-sellers (since I’m neither).

Moving Forward
The project todo list stands, and is very important to me (as it contains user feedback), but now I have priorities.

  1. Quicker User Interface:
    Technically there’s nothing wrong with the speed, but people feel they are typing too much. To solve this we’re going to aim for full ebay integration… the less you have to type the better !
  2. Flexibility:
    I’m going to add fees flexibility for non “.co.uk” and “power sellers” users can select their fee scheme. This flexibility is going to extend to the user interface – I’m going to jump on the ajax bandwagon – This part of development may be a little slow, but should be very exciting for my faithful users.

As always suggestions and feedback are welcome, and fingers crossed I’ll be ready for next x-mas ;)