Forums

How to use a custom field value as a search string? (2 posts)

  1. enrmalgrat
    Member
    Posted 3 weeks ago #

    I have a custom field called "city" and I would like to use the value of this custom field as a search string.

    I need this because I want to display on a given page all the posts that have the string.

    Anybody could help me with the php code please?

    Thank you in advance!

  2. MichaelH
    moderator
    Posted 3 weeks ago #

    Use get_post_meta to get that custom field and value, then use the Custom Field Parameter such as

    query_posts('meta_key=city&meta_value='.$value_from_get_post_meta);

Reply

You must log in to post.

About this Topic