/ Published in: PHP
second level of categories (when offset=-1 doesn't work, like for "get_category_link()"), pictures must be called exactly like category slug and placed to "catimg" folder. also i used "substr" for cut decription (314 symbols but you can change it). UPDATE: substr() replaced for mb_substr cause of unicode unknown symbols in cyrilic. UPDATE2: replaced mb_substr for function (http://snipplr.com/view/67430/cut-string-without-partial-words-unicode-version-with-mbsubstr/), now we have only full words, no partial.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $query = "SELECT b.name, b.slug, description, b.term_id FROM $wpdb->term_taxonomy AS a LEFT JOIN $wpdb->terms AS b ON ( b.term_id = a.term_id) WHERE a.parent = $cat AND a.taxonomy = 'category'"; $_ativis = $wpdb->get_results($query, OBJECT); ?> <?php foreach ($_ativis as $_ativi) : ?> <?php $link = get_category_link($_ativi->term_id); $excerpt = descr_excerpt($_ativi->description, 180); ?> <?php echo '<li><a href="'. $link .'"><img class="podcatsimg" src="catimg/' . $_ativi->slug . '.jpg"><p><span>' . $_ativi->name . '</span></p></a><p>' . strip_tags($excerpt) . '...</p></li>' ?> <?php endforeach; ?>