Get Address - Custom Function
Replied to your question via Forum.
In order to "minimize" the changes to core files, I've begun building functions that print what I want and how I want it. Here is an example (and I always protect my functions file on upgrade, not to mention zip/backup the entire site in case I loose anything while trying to upgrade):
ADD THE FOLLOWING LINES TO YOUR FUNCTIONS.PHP FILE IN THE PROPER BOTTOM SECTION
Code:
function cp_make_address_block ($smID, $smIDType, $smGetType) {
//gets the address based on the postID
if($smIDType == 'listing') {
$make_address = "";
$make_address = get_post_meta($smID, 'cp_street', true) . '
';
$make_address .= get_post_meta($smID, 'cp_city', true) . ',' . get_post_meta($smID, 'cp_state', true) . '' . get_post_meta($smID, 'cp_zipcode', true);
$make_address = trim($make_address, ',');
}
return $make_address;
}
Now anywhere I want to place the address of the listing, I simply call this function:
Code:
<?php echo cp_make_address_block ($post->ID, 'listing', 'addressblock') ?>
You could paste the address of the listing all over the place. But primarily so far I have used this to paste the address block in the Poster tab when viewing an ad.
You can probably see it looks like you could pass it several different variables. I'm getting it ready for the mod where we add the "address" field to the author, and we may for example only want to get the State (like you have in your homepage featured area). Soon I'll upgrade the function so that you can get the address of the author or the listing ad address, and then you can only get parts of the address, like the state, here is an example of what a future code might look like to call the "Author's" "State"
Code:
<?php echo cp_make_address_block ($post->ID, 'author', 'state') ?>
Obviously I'm getting this code ready for use with our "author address auto-completing the fields in the submit ad page". This is just version 1 of this function. Let me know what you think and come back often for updates. I'll post new versions here.