PHP Noob – How do I bring these two things together?
-
Hi everybody, I’m a bit of a PHP noob and I’ve hit a snag with my template. Here’s my problem:
I’m building a page template that will list of 17 different categories and give you the option to donate to them or to click their amazon affiliate link. This is what it looks like right now:
<?php $args=array( 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '1,8' ); $categories=get_categories($args); foreach($categories as $category) { echo '<div class="donateamazon"><a href="#paypal"><img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/donate-showblue.png" width="156" height="31" alt="Donate to this Category" /></a></div><div class="donateamazon"><a href="#amazon"><img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/amazon-showblue.png" width="156" height="31" alt="Shop Amazon for this Show" /></a></div>' ; } ?>
The two relevant links in here are currently placeholders, #paypal and #amazon. These are where I’m having trouble. These links are different for each category, and up until now I’ve been storing them as a big if else file and loading it as a template part. Like this (only with a bunch more elseifs in the real thing):
<?php if(is_category(364) ) { echo 'Paypal link #1'; } elseif(is_category(4) ) { echo 'Paypal link #2'; } else { echo 'Generic Paypal link'; } ?>
I just can’t figure out is how to integrate my giant list of links into the category listing above. Anybody have any ideas?
- The topic ‘PHP Noob – How do I bring these two things together?’ is closed to new replies.