SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict maxy22's Avatar
    Join Date
    Dec 2004
    Location
    here
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Top Posts from category

    I am trying to display the top rated posts from a category, for that I need to pass the cat-id variable to wp-postratings

    here is what i have done, but it isnt working, I suspect some problem with the code
    is the cat_id being correctly saved and passed to get_highest_rated_category function



    <?php function getCurrentCatID(){
    global $wp_query;
    if(is_category() || is_single()){
    $cat_ID = get_query_var('cat');
    }
    return $cat_id;
    }

    ?>

    <?php if (function_exists('get_highest_rated_category')): ?>
    <ul>
    <?php get_highest_rated_category($cat_id); ?>
    </ul>
    <?php endif; ?>

  2. #2
    SitePoint Addict maxy22's Avatar
    Join Date
    Dec 2004
    Location
    here
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just in case someone is wondering
    here is the correct working code

    Code:
    <?php if (function_exists('get_highest_rated_category')): ?>
    
    
       <ul>
       	<?php
       	$cat_id = get_query_var('cat');
    
    
           get_highest_rated_category($cat_id); ?>
       </ul>
    <?php endif; ?>

  3. #3
    SitePoint Addict maxy22's Avatar
    Join Date
    Dec 2004
    Location
    here
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK
    I also want the above to work on the post pages, for that I need to get the cat -d from the category slug
    and than run the above
    however, I am not sure about the if else if correct syntax in php

    here is what I have , can someone look and tell what's wrong?

    PHP Code:
    <?php if (function_exists('get_highest_rated_category')):  ?>  
      
      <ul>
    <?php if ( is_category()) 
       
           
    $cat_id get_query_var('cat');   
      
      
       
    get_highest_rated_category($cat_id); 
       
       

       </
    ul>  
    <?
    php  else { if (is_single()) 
      
     <
    ul
    $theCatId get_term_by'slug' );
     
    get_highest_rated_category($theCatId);    ?> 
    </ul> 
      
    <?php endif; ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •