[wp-hackers] Publish is hardcoded for Categories and Archives
peter at j1ve.com
Mon Dec 26 22:57:02 GMT 2005
I too am facing this problem (below) with a plug-in I'm working on.
> > > If there are any extra hooks you need added, let us know now and we
> > > try to get them into 2.0.
> > The biggest thing that's been missing is that the posts_where and
> > posts_join filters aren't called when constructing archives (date or
> > category), meaning the archives can't take into account the private
> > posts (since post_status = 'publish' is hard coded).
> I thought we always called those filters. Maybe I'm not following. Can
> you elaborate a bit more?
I switched topics without introducing the issue, my fault. My plugin
depends on post_status being set to private for the protected posts.
Those posts are then shown through the posts_where and posts_join
filters. However, this technique doesn't work for list_cats, etc
because those filters aren't applied to the SQL queries which generate
For example: Looking at template-functions.php, line 305, you can see:
$cat_dates = $wpdb->get_results("SELECT category_id,
UNIX_TIMESTAMP( MAX(post_date) ) AS ts
FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
WHERE post_status = 'publish' AND post_id = ID $exclusions
GROUP BY category_id");
As you can see, the SQL query is run without any filters, so my plugin
can't change the query to account for private posts. For another
example, see template-functions-general.php, line 333. You'll see:
$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS
`year`, MONTH(post_date) AS `month`, count(ID) as posts FROM
$wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00
00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date),
MONTH(post_date) ORDER BY post_date DESC" . $limit);
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the wp-hackers