Plot location on Google map using full address specified in custom field

Dean, your best bet is to do it through JS on the front end. I use the following function to covert the postcode to a Lat and Lng: function codeAddress(address){ geocoder.geocode({ ‘address’: address }, function(results, status){ if(status == google.maps.GeocoderStatus.OK){ map.setCenter(results[0].geometry.location); map.setZoom(16); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); markersArray.push(marker); // BA Lng, … Read more

Efficiently sort only certain categories by custom field

I would suggest to hook onto pre_get_posts and alter the query, rather than firing off your own in the template (it keeps your template tidy, and you’ll avoid doubling your database queries!). Below demonstrates this, plus a bonus settings field in the admin (under “Reading”) to select the categories that “special sorting” applies to – … Read more

How Do I Display A Custom Field In The Sidebar Of All My Pages?

I checked the code in the repository, and this specific function doesn’t have an ID parameter, meaning that it only grabs the CF of the current post/page being displayed. A fast solution would be: $my_page = get_page_by_path( ‘my-page’ ); $meta_values = get_post_meta($my_page->ID, ‘custom-field-name’, true); Maybe the plugin has another function for that, but you’d better … Read more

Get post ids sorted by meta_key

It’s easy. 🙂 You would use get_posts function. See WP_Query class for complete list of parameters that you can use. function get_posts_by_view_count() { $ids = array(); $args = array( ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘meta_key’ => ‘post_view_count’ ); $posts = get_posts( $args ); if( $posts ) { foreach( $posts as $post ) { $ids[] … Read more