• I’m using WP_Query to generate a custom search results page that displays posts under custom taxonomy terms.

    The thing with this is, I want to be able to have duplicate posts in the search results as one post might be assigned multiple terms.

    What i currently have is the order of the posts i want in a single dimensional array:

    eg: array ( 1, 2, 3, 1, 2, 3, 1, 2, 3 )

    (ill be able to determine the terms for each myself and generate the headers accordingly)

    The issue is when I pass this array to post__in it will only display the posts once.

    Is there anyway around this without modifying the WP Core.

    Thanks,

    Matt

Viewing 3 replies - 1 through 3 (of 3 total)
  • loop through your array and use get_post() or a query for each individual id?

    Thread Starter caddoo

    (@caddoo)

    The reason i’m using WP_Query is so i can use the inbuilt pagination.

    Doing it without the WP loop will prevent this if im right?

    Thread Starter caddoo

    (@caddoo)

    Looking into query.php

    I can see wordpress uses the MySQL syntax ‘IN’ and MySQL will never return the same row twice.

    } elseif ( $q['post__in'] ) {
    			$post__in = implode(',', array_map( 'absint', $q['post__in'] ));
    			$where .= " AND {$wpdb->posts}.ID IN ($post__in)";

    Ill have to write my own option i think and hook it into WP_Query

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_Query and post__in’ is closed to new replies.