Plugin Directory

Changeset 2438556


Ignore:
Timestamp:
12/14/2020 12:04:55 AM (5 years ago)
Author:
jhackett1
Message:

Fix readme formatting problem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-geo-search/trunk/readme.txt

    r2438554 r2438556  
    2929
    3030
    31 ```
     31`
    3232$query = new WP_Query(array(
    3333    "geo_query" => array(
     
    4242    )
    4343))
    44 ```
     44`
    4545
    4646Optionally, you can then filter by search radius.
     
    4848By default, distances are given in miles. You can provide `"units" => "km"` if you need kilometres.
    4949
    50 ```
     50`
    5151$query = new WP_Query(array(
    5252    "geo_query" => array(
     
    5656    )
    5757))
    58 ```
     58`
    5959
    6060Or order by nearness:
    6161
    62 ```
     62`
    6363$query = new WP_Query(array(
    6464    "geo_query" => array(
     
    6868    "orderby" => "geo"
    6969))
    70 ```
     70`
    7171
    7272### Displaying distance in templates
     
    101101You could also hook into the `save_post` action to populate meta whenever you create or change a post, by adding a snippet like this to your theme's `functions.php`:
    102102
    103 ```
     103`
    104104function example_update_latlngs($post){
    105105    $location = get_field("location", $post);
     
    111111
    112112add_action("save_post", "example_update_latlngs", 10, 3);
    113 ```
     113`
    114114
    115115This example assumes you are using an [ACF Google Map](https://www.advancedcustomfields.com/resources/google-map/) field called "location", but the data could come from anywhere, including a custom meta box you code yourself, so long as the post meta keys are right.
     
    119119If you have many posts that you need to add longitude and latitude meta to in bulk, you could add something like this to `functions.php`, which will run on [theme activation](https://developer.wordpress.org/reference/hooks/after_switch_theme/):
    120120
    121 ```
     121`
    122122function example_update_all_latlngs(){
    123123    $query = new WP_Query(array(
     
    131131
    132132add_action('after_switch_theme', 'example_update_all_latlngs');
    133 ```
     133`
    134134
    135135
Note: See TracChangeset for help on using the changeset viewer.