• I’m having trouble calling the wp_get_archives function using the “postbypost” type. It’s returning duplicates and I’ve tracked it down to the query joining on the wp_term_taxonomy table where there are multiple entries in this table per post. This appears to be because I have multiple categories assigned to some posts. Those assigned to just one category display twice whereas those assigned to multiple categories show even more times.

    Here’s how I’m calling the function for my left sidebar/column:

    wp_get_archives(‘type=postbypost&limit=10’);

    Is this supposed to work this way?

    Any ideas greatly appreciated!

    ~ Jenifer

Viewing 3 replies - 1 through 3 (of 3 total)
  • Using the WordPress Default Theme, no plugins active, changed sidebar.php to use<?php wp_get_archives('type=postbypost&limit=4'); ?> and it did NOT duplicate any posts, even if the posts had 1,2, or 3 categories assigned.

    Wonder if you have a plugin causing that problem?

    Thread Starter llewellynworld

    (@llewellynworld)

    hmm… could be. All I had at the time was the Role Scoper plugin and the Top Level Categories plugin installed. Here’s the query that the wp_get_archives function is executing:

    SELECT * FROM wp_posts LEFT JOIN wp_term_relationships AS tr ON wp_posts.ID = tr.object_id LEFT JOIN wp_user2role2object_rs AS uro ON uro.obj_or_term_id = wp_posts.ID AND uro.src_or_tx_name = ‘post’ AND uro.scope = ‘object’ AND uro.assign_for IN (‘entity’, ‘both’) AND uro.group_id IN (‘1’) WHERE wp_posts.post_date > 0 AND post_type = ‘post’ AND post_status IN (‘publish’, ‘private’) ORDER BY post_date DESC LIMIT 10

    It’s the term_taxonomy_id column in the query that’s causing the duplicates. I guess I need to figure out what that table is used for and why my install is causing duplicates.

    Jenifer

    I had exactly the same problem, and as a result of reading this thread I deactivated Role Scoper: which fixed it. Thank you!

    (I’ve posted this to the plugin’s forum.)

    Best wishes,

    Michael

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_get_archives, postbypost, duplicates – taxonomy?’ is closed to new replies.