Forums

[resolved] custom query with page__in not working (6 posts)

  1. JAWEL_
    Member
    Posted 9 months ago #

    I'm trying to get the posts from a specific category, where the title contains a specific word. As long as I leave the 'post__in' out of the query I get results. Does anyone know what I'm doing wrong?

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. alchymyth
    The Sweeper
    Posted 9 months ago #

    As long as I leave the 'post__in' out of the query I get results

    sounds ok - what results?
    and are these the results you are looking for?

    general:
    http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

    'post__in' properly used is to get posts with certain IDs;

  3. JAWEL_
    Member
    Posted 9 months ago #

    sorry, pasted too long code.
    Here's the code in the right way:
    http://pastebin.com/e2wn6iiB

    @alchymyth: query selects posts in certain categories, using 'category__and'.
    The right posts are selected.
    By using 'post__in' I try to narrow down the selection of posts to only posts containing a certain word (eg. "verander") in the title.
    When I add this, I get no results at all.

  4. Big Bagel
    Member
    Posted 9 months ago #

    Did you make sure your $wpdb query is returning the proper stuffs? Try a var_dump on $mypostids just to make sure. It might also be useful to do the same with $args just to make sure everything is happy.

  5. JAWEL_
    Member
    Posted 9 months ago #

    Finally got it working.
    The searches I tried only came up with posts that didn't belong to selected categories.
    Here's the working code:
    http://pastebin.com/BKgspJ7g

    The script uses three query_vars;
    pub_search, pub_categorie and pub_author
    that are setup in the functions.php
    It searches the title and content of the posts belonging to the categories stored in pub_categorie and pub_author

  6. JAWEL_
    Member
    Posted 9 months ago #

    tnx @alchymyth and @Big Bagel

Reply

You must log in to post.

About this Topic