WordPress.org

Ready to get started?Download WordPress

Forums

retrive category posts using custom field values (2 posts)

  1. muralikalpana
    Member
    Posted 3 years ago #

    hello....

    i have three categorys. in that 'news' is one of the category. that category posts having custom field key named as 'ratings'. giving rating values between 0-9.

    i want to display 5 posts in my sidebar of top ratings. how to display. i am new to wordpress. please help me.....

    thanks

  2. muralikalpana
    Member
    Posted 3 years ago #

    actually i am displaying like this. but this is displaying last five ratings only.but i want to display top five ratings from category 'news id=9' posts.`<ul>
    <?php

    query_posts($query_string . '&cat=9&meta_key=ratings'); ?>

    <?php
    $i=0;
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( function_exists('get_custom_field_value') ){
    $caticons_ratings=get_custom_field_value('ratings', false);
    //echo $caticons_ratings;
    if($i<5)
    {
    if($caticons_ratings>5)
    {
    ?>
    <li><div class="list_items_image"><div class="attach_musicimg"><a href="<?php echo get_bloginfo(url)?>?artist=<?php the_author(); ?>"><?php the_post_thumbnail(); ?></a></div></div><div class="list_items_desc">
    <?php the_title(); ?><p><a href="<?php echo get_bloginfo(url)?>?artist=<?php urlencode(the_author()); ?>" class="pink_text"><?php the_author(); ?></a>
    <br /><img src="<?php bloginfo('stylesheet_directory'); ?>/images/star<?php echo $caticons_ratings;?>.gif" /> <?php echo $caticons_ratings.'/10';?>
    </p>
    </div></li>
    <?php $i++;}}}?>
    <?php endwhile;?>

    <?php endif; ?>
    </ul>`

Topic Closed

This topic has been closed to new replies.

About this Topic