• I use a relatively simple and rather outdated plugin to make a page with an alphabetical list of post titles. When I looked for such a plugin, this was the only one that does most of what I want and when I look for alternatives, this little one remains the best. Now I have a wish for it that I can’t create myself. I want to exclude categories from the list. The comment list of the plugin gives the following two options in which the bold lines are added to the plugin file:

    $sql = “SELECT p.post_title, p.ID
    FROM $wpdb->posts p,
    $wpdb->term_relationships t
    WHERE p.post_status = ‘publish’
    AND p.post_password = ”
    AND p.ID = t.object_id
    AND t.term_taxonomy_id != ‘5’
    AND t.term_taxonomy_id != ‘6’ “;

    $Results = $wpdb->get_results($sql);

    $sql = “SELECT p.post_title, p.ID
    FROM $wpdb->posts p,
    $wpdb->post2cat p2c
    WHERE p.post_status = ‘publish’
    AND p.post_password = ”
    AND p.ID = p2c.post_id
    AND p2c.category_id != ‘5’
    AND p2c.category_id != ‘6’ “;

    $Results = $wpdb->get_results($sql);

    Both additions give me parse errors, so my question is, what can I add to exclude categories?

    [edit] For a second I thought it was easy and I just needed to put an ) before the ; in the last AND line, but that’s not it.

Viewing 1 replies (of 1 total)
  • Thread Starter Roy

    (@gangleri)

    Now that I notice a few users online who are better in coding than myself, I’m bumping this thread 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Alphabetical index plugin’ is closed to new replies.