• I use the following code to display the total posts of a category:
    < ? php $count = $wpdb->get_var("SELECT category_count FROM $wpdb->categories WHERE cat_ID=7"); echo $count; ? >

    What happens with the next line which I use pretty often in my templates:
    < ? php query_posts("cat=7&showposts=3"); ? >

    And last but not least I suppose the var $cat probably will not work anymore (I use it to display category specific content and more)

    < ? php
    $headerline = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat");
    $headerline= strtolower($headerline); echo $headerline;
    ? >

    Will all this (not) be valid for the next version?

Viewing 1 replies (of 1 total)
  • Thread Starter karimun

    (@karimun)

    Well guys, I did some try&error with the v2.3 beta3 copy now and found out how to solve my probs mentioned above.

    Retrieve current category ID or category name:

    < ? php
    foreach((get_the_category()) as $category) {}
    $cat = $category->cat_ID;
    $catname = $wpdb->get_var("SELECT name FROM $wpdb->terms WHERE term_ID=$cat");
    echo $cat ." - ". $catname;
    ? >

    Total posts in a specific category (could be combined with the code above):

    < ? php
    $totalposts = $wpdb->get_var("SELECT count FROM $wpdb->term_taxonomy WHERE term_ID=THE_CAT_ID");
    ? >

    Show certain numbers of posts of specific category(same as for v2.2.x; place it above the loop):
    < ? php query_posts("cat=7&showposts=3"); ? >

    Maybe someone finds it helpful.

Viewing 1 replies (of 1 total)
  • The topic ‘Will this work in v2.3 ?’ is closed to new replies.