i need some help with a little problem that occurred today.
To show the latest posts in website, i use this script, also this script exclude some categories (my website is not in wordpress,but the db names has wp in front)
SELECT
ID,
post_title,
post_content,
post_date,
GROUP_CONCAT(DISTINCT post_category ORDER BY post_category DESC SEPARATOR ", " ) as "categories"
FROM
wp_posts,
wp_term_relationships,
wp_term_taxonomy
WHERE wp_posts.post_status = "publish"
AND wp_term_relationships.object_id = id
AND wp_term_taxonomy.taxonomy= "category"
AND !(wp_term_taxonomy.term_taxonomy_id = 34472 ||
wp_term_taxonomy.term_taxonomy_id = 34473 ||
wp_term_taxonomy.term_taxonomy_id = 34474 ||
wp_term_taxonomy.term_taxonomy_id = 17)
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
GROUP BY ID, post_title, post_content, post_date
ORDER BY wp_posts.post_date DESC LIMIT 150
Now the problem is that i need to get only the today posts, so i add to this script this:
AND DATE(post_date) >= CURRENT_DATE
but after adding this, i see that many posts that are in some categories not only one, they are showed twice or more times.
Can some one help me to solve this issue?
Thank you
Please help.
Since
post_dateis part of your GROUP’ing, you should add the following right after theGROUP BYclause and before theORDER BYclause (don’t use it as aWHEREclause):