PHP Code Help for Archive Timeline Plugin
-
I’m trying to change the WordPress Archive Timeline Plugin http://www.lalala.fr/blog/?p=25
so that I can have posts show only in the timeline archive per the category showing. (I’ve left a post at the authors site and have emailed but I can’t seem to get a response.)Basically I want posts related to category selected by viewer to show in the archive.
Here’s the original code where I am thinking to change so it will only show the category posts (not my entire archive of posts):
// Get all posts
$posts = $wpdb->get_results(
“SELECT post.* FROM $tableposts as post WHERE post.post_status=’publish’ ORDER BY post.post_date DESC” . $Limit
);The code I’ve changed/added:
I’ve added the global variable (note: I’m not very PHP literate) $tablepost2cat so I can pull only the category posts for that page. I’m calling the plugin from within my category.php file.
function wp_timeline() {
global
$wpdb, $tableposts, $tablepost2cat, $wp_query,
$IMAGE_URI, $MAX_NB_POSTS, $TIMELINE_URI, $USE_TITLES, $THEME_URI;// Get all posts
$posts = $wpdb->get_results(
“SELECT post.* FROM
$tableposts as post,
$tablepost2cat as post2cat
WHERE
(post.post_status=’publish’) AND
(post2cat.category_id=$category->cat_ID) AND
(post2cat.post_id=post.ID)
ORDER BY post.post_date DESC” . $Limit
);Here’s the error received:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) AND (post2cat.post_id=post.ID) ORDER BY post.post_date DESC’ at line 6]
SELECT post.* FROM wp_posts as post, wp_post2cat as post2cat WHERE (post.post_status=’publish’) AND (post2cat.category_id=) AND (post2cat.post_id=post.ID) ORDER BY post.post_date DESC—-
So, I must have my query and/or syntax wrong but since I’m not fluent with MYSQL or PHP I’ve not been able to fix this.Could someone point out where I’m going wrong?
- The topic ‘PHP Code Help for Archive Timeline Plugin’ is closed to new replies.