get the LEAST popular posts from specific category (or except category)
-
I want to show least viewed posts from all categories except one,
by this code I can show least viewed posts : source
and with below code, I can show all posts except posts belong to specific category (form example cat with id=73)
$query ="
SELECT *
FROM wp_posts
LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE wp_term_taxonomy.term_id NOT IN (73)
GROUP BY wp_posts.ID limit 2";
/---- FOR DISPLAY RESULT -----/
$resultfirst = $wpdb->get_results($query);
foreach( $resultfirst as $result ){
echo $result->post_title;
echo ' - ';
}Is there a way to combine these two codes? In such a way that the posts with the least visits are displayed, provided that they are not from category 73
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.