$terms = get_terms('custom-post-type-name');
foreach ($terms as $term) {
$wpq = array ('taxonomy'=>'custom-post-type-name','term'=>$term->slug);
$myquery = new WP_Query ($wpq);
$article_count = $myquery->post_count;
echo "<h3 class=\"term-heading\" id=\"".$term->slug."\">";
echo $term->name;
echo "</h3>";
if ($article_count) {
echo "<ul>";
while ($myquery->have_posts()) : $myquery->the_post();
echo "<li><a href=\"".get_permalink()."\">".$post->post_title. "</a></li>";
endwhile;
echo "</ul>";
}
}
source
To set your favorite permalink structure from the beggining, add this on functions.php:
Continue Reading →
OK this one was tricky, but resolved. With this method you can display most popular posts by views (not by comments, in my casi I hadn’t comment on each post). It uses a custom-value that records each hit on each post and then it is possible to query them by meta-value:
Add this on functions.php:
Continue Reading →
Easy one: this function redirects any user that hasn`t administrator capabilities to que home page of your site, if they try to access wp-admin/
Continue Reading →
With this PHP function you can create a hierarchical and navigational menu for your pages in WordPress. It will take the top parent page and keep it as a title, and then build their children pages keeping the hierarchy and the same markup used in wp_list_pages();
Continue Reading →