Getting double/triple posts listed on some blogs

View: New views
3 Messages — Rating Filter:   Alert me  

Getting double/triple posts listed on some blogs

by Michael C. Duterte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,

Need some help with a sql that is being generated after a plugin adds a
join and a where clause. On some systems, the sql below is somehow
causing WordPress to list double or triple (duplicate) posts but it
works perfectly on most systems. I'm stumped, can somebody give any
clues as to why this is happening?

|SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN
wp_postmeta AS _plug_join ON wp_posts.ID = _plug_join.post_id AND
_plug_join.meta_key = '_plug_access' WHERE 1=1 AND (post_type = 'post'
AND (post_status = 'publish')) AND _plug_join.meta_value != 'P' ORDER BY
post_date DESC LIMIT 0, 10|


Thanks,
Mike
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Getting double/triple posts listed on some blogs

by Knut-Olav Hoven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 07 February 2007 15:47, Michael C. Duterte wrote:
> Hi Guys,
>
> Need some help with a sql that is being generated after a plugin adds a
> join and a where clause. On some systems, the sql below is somehow
> causing WordPress to list double or triple (duplicate) posts but it
> works perfectly on most systems. I'm stumped, can somebody give any
> clues as to why this is happening?

The same happended to me with WordPress 2.1.

You might use the filter hook 'posts_distinct' and return 'DISTINCT', without
quotes, from the callback function.


--
Knut-Olav Hoven
Linpro AS                    http://www.linpro.no/
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Getting double/triple posts listed on some blogs

by Michael C. Duterte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Knut-Olav Hoven wrote:

> On Wednesday 07 February 2007 15:47, Michael C. Duterte wrote:
>  
>> Hi Guys,
>>
>> Need some help with a sql that is being generated after a plugin adds a
>> join and a where clause. On some systems, the sql below is somehow
>> causing WordPress to list double or triple (duplicate) posts but it
>> works perfectly on most systems. I'm stumped, can somebody give any
>> clues as to why this is happening?
>>    
>
> The same happended to me with WordPress 2.1.
>
> You might use the filter hook 'posts_distinct' and return 'DISTINCT', without
> quotes, from the callback function.
>
>
>  

That fixed it. Didn't know that hook exists, thanks a lot.
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers