• Resolved matt_ny

    (@matt_ny)


    Hi everyone.

    I’m trying to print out my posts using name__like (works for tags), but wordpress seems to not support this.

    Is it hard to implement?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • See if you like what the ‘name=’ argument gets you. Otherwise you’d need to create a filter using ‘posts_where’ hook. See Custom_Queries.

    name__like is pretty much the same as using the search feature, it takes the value given and runs it inside a search, ie. %search_term% inside the MySQL line…

    It actually operates much in the same way, this is essentially your equivalent for query/get_posts.

    $searchterm = 'your search term';
    query_posts( 'whatever_other_args_you_have_etc&s=' . $searchterm )

    HOWEVER! There is one catch, post searches do look inside fields beyond the name(in the case of a post the title – in the case of a term, the term name), so it does have a drawback in that it would run the search term across the post_content and other areas, which may not be what you’re after.

    So all that said and done, as Michael suggests above, you’ll need to look at a posts_where filter, just thought i’d point out there is already an equivalent, it just may not be suitable in what you’re aiming for.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘name__like statement for posts’ is closed to new replies.