Forums

Having an issue doing a WP_Query with post_content and category__and (2 posts)

  1. shawntribal
    Member
    Posted 8 months ago #

    This is the array for my arguments for the WP_Query.

    Array
    (
        [showposts] => 4
        [paged] => 1
        [post_type] => post
        [post_content] => tree
        [category__and] => Array
            (
                [0] => 6
                [1] => 15
                [2] => 28
            )
    
    )

    I want to return the posts where they are in the categories 6, 15, 28 and where the post_content has the word tree.

    My problem is that I'm returning several duplicated results for the posts that have the word tree in it. Ideally I would like to return one.

    anyone have any idea how I can fix or improve this?

  2. shawntribal
    Member
    Posted 8 months ago #

    I found the issue, I shouldn't have been trying to filter on post_content, but rather 's'

    e.g.

    Array
    (
        [showposts] => 4
        [paged] => 1
        [s] => post
        [post_content] => tree
        [category__and] => Array
            (
                [0] => 6
                [1] => 15
                [2] => 28
            )
    
    )

Reply

You must log in to post.

About this Topic

Tags