[caption id="attachment_260" align="alignnone" caption="Top banner"][/caption]
[function.mysql-connect] =
http://synad2.nuffnang.com.my/function.mysql-connect
[caption id="attachment_261" align="alignnone" caption="Between post"][/caption]
[function.mysql-connect] =
http://synad2.nuffnang.com.my/function.mysql-connect
<?php
/* This funtion will display posts for each parent categories */
function posts_by_cats($num_of_posts) {
global $wpdb;
// query the cat id
// remove `parent` = 0 to display all categories
$sql = "SELECT `term_id` FROM $wpdb->term_taxonomy WHERE
`taxonomy`='category' AND `parent` = 0 AND `count` != 0";
$cats = $wpdb->get_results($sql, ARRAY_A);
//display posts for each cat
foreach ($cats as $cat) {
$cat_id = $cat['term_id'];
// query the cat name
$sql = sprintf("SELECT `name` FROM $wpdb->terms
WHERE `term_id`=%d", $cat_id);
$cat_name = $wpdb->get_var($sql); echo '';
echo '<h3><a href="'. get_category_link($cat_id)
. '">' . $cat_name . '</a></h3>';
// query all the posts for each cat
query_posts(sprintf("cat=%d&showposts=%d", $cat_id, $num_of_posts));
// the loop
if (have_posts()) :
echo " <ul>";
while(have_posts()) : the_post(); ?>
<li><a title="<?php the_title_attribute(); ?>"
href="<?php the_permalink() ?>"
rel="bookmark"><?php the_title(); ?></a>
<?php endwhile;
echo '<li><a href="'. get_category_link($cat_id)
. '">(more)</a></li>';
echo "</ul>"; endif; echo " "; } } ?>
</li> </ul>
If you run more than one ads, but lack of space to put the ads, you can actually rotate the ads.
The code below will create a random number from 1 to 10. Since I want both ads to be shown with a probability of 50%, I put the condition if (x > 5)
. However, you can change this number.
Options All -Indexes
<files xmlrpc.php>
SecFilterInheritance Off
</files>
http://rpc.technorati.com/rpc/ping