WordPress.org

Ready to get started?Download WordPress

Forums

Business Directory Plugin
[resolved] How to search only beginning of a field by modifying SQL query? (2 posts)

  1. chrisdadd
    Member
    Posted 1 year ago #

    I'm offering a search by postcode option but I only want results to match the beginning of the text field.

    As an example, I've added postcode as a custom field and added two businesses with the postal codes E2JABC and ABC123. When I search for ABC I get both listings.

    Where is the SQL query run?

    I can get the results in myphpadmin with the query

    SELECT *
    FROM np_8_postmeta
    WHERE meta_key = "_wpbdp[fields][13]"
    AND meta_value LIKE "n11%"
    LIMIT 0 , 30

    How could I modify the php to allow for this condition ie starting with the entered postcode.

    My concern is that the code change will likely affect both the postal code and the town/city as well, whereas I'd prefer it to be field specific.

    All thoughts appreciated.

    Chris

    http://wordpress.org/extend/plugins/business-directory-plugin/

  2. businessdirectoryplugin
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Chris,

    To make a change like that, you'll have to modify the core of the plugin to handle it. The query gets run api/listings.php, look for the "search" method.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic