So I have a basic loop on category.php that displays all posts from the specific category, like this:
<?php if (have_posts()) :
while(have_posts()): the_post();
?>
<a href="<?php the_permalink(); ?>">
<div>
<h3><?php echo the_title();?></h3>
<p><?php echo the_content(); ?></p>
</div>
</a>
<?php
endwhile;
endif;
?>
I have another loop on another page that displays the most liked posts (posts in order of the number of their likes). That loop is:
<?php
$query_args = array(
'post_type' => 'post',
'posts_per_page' => 2,
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'Likes',
'compare' => 'NOT EXISTS',
'type' => 'numeric'
),
array(
'key' => 'Likes',
'compare' => 'EXISTS',
'type' => 'numeric'
)
)
);
$loop = new WP_Query($query_args);
if ($loop->have_posts()):
while($loop->have_posts()):
$loop->the_post();
?>
<a href="<?php the_permalink(); ?>">
<div>
<h3><?php echo the_title();?></h3>
<p><?php echo the_content(); ?></p>
</div>
</a>
<?php
endwhile;
endif;
?>
So now I want another loop inside category.php that displays posts from the specific category based on the number of likes, or in other words, popular posts from that category. How do I go about combining these two loops to achieve that? Any help will be highly appreciated.
Cheers.