Actually I'm using this loop to get my posts in homepage:

                    <ul class="news">
// The query
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$additional_loop = new WP_Query("posts_per_page=10&category__not_in=3&category__not_in=15,&paged=".$page);
// The Loop
while ($additional_loop->have_posts()) : $additional_loop->the_post();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'latesthome');
$url = $thumb['0'];
                            <a href="<?php the_permalink() ?>">
                                <span class="articleimg" style="background-image: url('<?php echo $url; ?>');"></span>
                                <span class="articletitle"><?php the_title(); ?></span>
                                <span class="articleinfo">di <?php the_author(); ?>, <?php the_time('j F Y'); ?> 
if (in_category('1')) { 
<span class="typetag article"></span>
                                    <?php }
else if (in_category('2')) {
                                    <span class="typetag review"></span>
                                    <?php }
// Reset Query

When I set a post as "featured" it remains at the top (as first element) of the list, so works really good.

But I need to assign a particular class to li of featured posts, like this:

<li class="hot">

How I can do this? I really have no idea.

  • 1
    How do you set post as featured? What kind of approach selected? – Ignat B. Sep 14 '15 at 14:09

I hope that "featured" will be a custom field of posts. In that case you can check the value of field using:

$desc = get_post_meta($post->ID, 'featured', true);

You can use if-else condition and check that if you get value=1 {or what you assigned for featured} then apply class"hot".

Give it a try.

best of luck

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.