Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gbot

    (@gbot)

    just reporting back, I’ve got a solution that works well for me, this SQL filters a variable passed into the funtion.

    $posts = $wpdb->get_results("SELECT DISTINCT ID, post_title FROM wp_alcoveposts
    LEFT JOIN wp_alcovepost2cat ON (wp_alcoveposts.ID = wp_alcovepost2cat.post_id)
    WHERE post_status='publish' AND (category_id NOT IN (" . $filter . ")) ORDER BY post_date DESC LIMIT " . $limit);

    hope that might help someone else… thanks

    Thread Starter gbot

    (@gbot)

    Hi there, thanks for your responses.

    That doesn’t seemt to work though – I think because the ‘post_category’ column in the posts table are all zeros. The category ids are stored in the post2cat table, and there can of course be multiple categories assigned to a given post, so they all need to be checked for category ’31’ (in this case).

    I think this requires a JOIN or UNION query or something like that, which I know very little about unfortunately… I will investigate further, thanks again.

Viewing 2 replies - 1 through 2 (of 2 total)