Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End posts_where hook

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #36220
    angelazou
    Participant

    I need to get a list of posts based a certain value in their meta key “所在房号”, which is actually a pattern.

    	$pattern = '/$floor(([0-2][0-9])|88)/';
    $args = array( 'numberposts' => $totalposts, 'category'=> $building, 'orderby' => $orderby, 'meta_key' => '所在房号', 'meta_value' => $pattern );
    $myposts = get_posts($args);

    So if $floor is 9, the function will match on the meta value that has value of 900-929, and 988 (anywhere in the string). But the problem is, someone told me that get_posts doesn’t accept regular expression, that I need a posts_where hook. I checked out the codex here http://codex.wordpress.org/Custom_Queries, but I just couldn’t figure out what to do with the function. It’s so confusing. Can someone explain it? or provide an example?

    Angela

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.