planetthoughtful
Forum Replies Created
-
Forum: Plugins
In reply to: Determining if current visitor has logged in?Hi podz,
Thanks for this, but I’m not trying to work out how many users are online, but if the page is being requested by a logged-in user.
I’m aware, for example of a global variable $user_level, which I check in one of my own plugins to see if I should display an ‘edit this’ link next to my footnotes.
I guess I could experiment with the availability of a $user_id variable, but was hoping someone could confirm or deny its existence up front.
But thanks, again, all the same!
Much warmth,
planetthoughtfulForum: Fixing WordPress
In reply to: Categories: counting posts & listing oldest firstNo problem at all, jarle, you’re very welcome!
I’d like to see this make its way into the WP distro, because I imagine we’re not the only ones disconcerted by a category post count of, say, 2 when only 1 post is actually viewable because the other one is future-dated.
Much warmth,
planetthoughtfulForum: Fixing WordPress
In reply to: Categories: counting posts & listing oldest firstHi jarle,
Don’t know about your second question, but if you’re comfortable modifying a little PHP, an answer to your first question would be to edit the following SQL statement in wp-includes/templates-functions-category.php from:
if (!count($category_posts)) {
$cat_counts = $wpdb->get_results(" SELECT cat_ID,
COUNT($tablepost2cat.post_id) AS cat_count
FROM $tablecategories
INNER JOIN $tablepost2cat ON (cat_ID = category_id)
INNER JOIN $tableposts ON (ID = post_id)
WHERE post_status = 'publish' $exclusions
GROUP BY category_id");
foreach ($cat_counts as $cat_count) {
if (1 != intval($hide_empty) || $cat_count > 0) {
$category_posts["$cat_count->cat_ID"] = $cat_count->cat_count;
}
}
}
To:
if (!count($category_posts)) {
$cat_counts = $wpdb->get_results(" SELECT cat_ID,
COUNT($tablepost2cat.post_id) AS cat_count
FROM $tablecategories
INNER JOIN $tablepost2cat ON (cat_ID = category_id)
INNER JOIN $tableposts ON (ID = post_id)
WHERE post_status = 'publish' and post_date < NOW() $exclusions
GROUP BY category_id");
foreach ($cat_counts as $cat_count) {
if (1 != intval($hide_empty) || $cat_count > 0) {
$category_posts["$cat_count->cat_ID"] = $cat_count->cat_count;
}
}
}
The significant edit is adding “and post_date < NOW() ” to the WHERE condition of the SQL statement. This will ensure that only posts with a post_date less than the current datetime are used to aggregate the count of posts in the categories list.
Note: by making this change if you have a category that only has one or more future-dated posts, that category will not show up in the category list until one of those posts becomes displayable (ie we reach the datetime preset on the post). At least, this is how making the change above works on my WP installation.
Hope this is of some help.
Much warmth,
planetthoughtfulForum: Plugins
In reply to: Where to begin with hacking WordPress?Thank both to Techgnome and Dennis Williamson! I’m well on the way to developing this plugin, with help from the references you provided.
Thanks again!
Much warmth,
planetthoughtfulForum: Fixing WordPress
In reply to: No posts being displayed in new install of 1.2.1?Hi,
It appears to have been caused by a problem cookie. Not sure how or why, but a clearing of my cookies in FireFox fixed the problem.
I only deduced this as a solution because I was receiving comments from posts that others could see but which I couldn’t.
So, I fired up IE and of course could see the posts.
Seemed sensible enough to clear FireFox’s cache and cookies, and hey presto, the posts were visible.Forum: Fixing WordPress
In reply to: Cannot post anythingAt a guess, since I had a very similar problem, try clearing out your cache and cookies.
I had a new install of WordPress go blank on me, yet could see the posts in the db.
Clearing out the cache and cookies seemed to do the trick.Forum: Plugins
In reply to: Post expires after set date or number of days.I confess, I don’t quite understand what is meant by the ‘automated’ option.
Would people want to purge old articles, even if they’re not visible anymore? Chances are, the moment they’re purged, someone is going to want the details again.
At worst, you could offer an admin purge process, which is probably more in keeping with maintaining the application contained within a PHP / MySQL solution base, rather than having to rely on timed cron jobs, which may or may not be available to some people wishing to use WordPress.
However, speaking as someone who would like to have the ‘expire’ functionality, I wouldn’t want posts automatically purged, unless there was another flag at post creation / edit time to control this behaviour.
As another alternative, an admin page that displays all expired articles and allows you to select those you wish to be purged?Forum: Plugins
In reply to: Post expires after set date or number of days.I may be missing something, as I’m very new to WordPress, but if WordPress is delivered via PHP / MySQL then wouldn’t activating post expiry be as simply as changing the SQL statements that draw the posts to something like this pseudo statement:
SELECT * from tblposts where displaydate > Now() and expiredate < Now()
I’m not suggesting the actual statement(s) would be that simple, but the point is, WordPress seems to dynamically draw its posts from the underlying database when each page is requested. You shouldn’t need Cron jobs etc to exclude expired posts, it should be possible to exclude them using the SQL that pulls the posts for display.
Again, could be wildly wrong.
Regards,
Murray