Below, you’ll find a detailed guide on how to add the AgentPress Listings Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the AgentPress Listings Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the AgentPress Listings Plugin and the shortcodes it provides:
"AgentPress Listings is a powerful WordPress plugin designed specifically for real estate websites. It allows you to easily manage and display property listings, enhancing your site's functionality."
- [property_details]
- [property_map]
- [property_video]
AgentPress Listings [property_details] Shortcode
The AgentPress-Listings shortcode ‘property_details’ is designed to display property details in a structured format. The shortcode fetches property details from post meta and organizes them into two columns. The first column contains the details from ‘col1’ and the second column from ‘col2’. Finally, it displays additional features of the property, fetched from the ‘features’ taxonomy. The output is wrapped in a div with a class of ‘property-details’ for styling.
Shortcode: [property_details]
Examples and Usage
Basic example – Showcases a simple use of the ‘property_details’ shortcode without any parameters.
[property_details /]
Advanced examples
The ‘property_details’ shortcode allows for more advanced usage by passing parameters, also known as attributes or ‘atts’, within the shortcode itself. These parameters can be used to customize the output of the shortcode, allowing for a more tailored display of property details.
For example, you can display property details for a specific post ID. This can be useful when you want to display details for a specific property in a post or page. Here’s how you would do it:
[property_details id=123 /]
Another advanced usage of the ‘property_details’ shortcode is to display certain columns of the property details. This can be useful when you want to limit the amount of information displayed. Here’s how you would do it:
[property_details columns="col1" /]
Or display both columns:
[property_details columns="col1,col2" /]
Please note that these advanced examples assume that you have modified the ‘property_details_shortcode’ function to accept and handle these parameters. The original function does not include these features.
PHP Function Code
In case you have difficulties debugging what causing issues with [property_details]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'property_details', array( $this, 'property_details_shortcode' ) );
Shortcode PHP function:
function property_details_shortcode( $atts ) {
global $post;
$output = '';
$output .= '<div class="property-details">';
$output .= '<div class="property-details-col1 one-half first">';
foreach ( (array) $this->property_details['col1'] as $label => $key ) {
$output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), wp_kses( get_post_meta( $post->ID, $key, true ), $this->allowed_tags ) );
}
$output .= '</div><div class="property-details-col2 one-half">';
foreach ( (array) $this->property_details['col2'] as $label => $key ) {
$output .= sprintf( '<b>%s</b> %s<br />', esc_html( $label ), wp_kses( get_post_meta( $post->ID, $key, true ), $this->allowed_tags ) );
}
$output .= '</div><div class="clear">';
$output .= sprintf( '<p><b>%s</b><br /> %s</p></div>', __( 'Additional Features:', 'agentpress-listings' ), get_the_term_list( $post->ID, 'features', '', ', ', '' ) );
$output .= '</div>';
return $output;
}
Code file location:
agentpress-listings/agentpress-listings/includes/class-agentpress-listings.php
AgentPress Listings [property_map] Shortcode
The AgentPress Listings plugin shortcode, ‘property_map’, generates a map for a specific property listing. This feature simplifies navigation for users. This shortcode retrieves and displays the custom field ‘_listing_map’, which holds the map data of the property.
Shortcode: [property_map]
Examples and Usage
Basic example – A simple usage of the ‘property_map’ shortcode to display the map related to a particular listing. The map is fetched using the listing’s custom field ‘_listing_map’.
[property_map id=1 /]
Advanced examples
Using the ‘property_map’ shortcode to display multiple maps for different listings. This can be achieved by using the shortcode multiple times with different id parameters. The id parameter corresponds to the unique identifier of each listing.
[property_map id=1 /]
[property_map id=2 /]
[property_map id=3 /]
Another advanced usage of the ‘property_map’ shortcode is to display a map along with additional information about the listing. This can be achieved by combining the ‘property_map’ shortcode with other shortcodes. For example, the ‘listing_info’ shortcode can be used to display information about the listing, while the ‘property_map’ shortcode displays the map.
[listing_info id=1 /]
[property_map id=1 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [property_map]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'property_map', array( $this, 'property_map_shortcode' ) );
Shortcode PHP function:
function property_map_shortcode( $atts ) {
return genesis_get_custom_field( '_listing_map' );
}
Code file location:
agentpress-listings/agentpress-listings/includes/class-agentpress-listings.php
AgentPress Listings [property_video] Shortcode
The AgentPress-Listings plugin shortcode, ‘property_video’, retrieves and displays the video related to a particular property listing. This shortcode taps into the Genesis framework, specifically the ‘genesis_get_custom_field’ function, to fetch the ‘_listing_video’ custom field. This field typically contains the URL or embed code of the property video. The ‘property_video’ shortcode thus provides a simple way to embed property videos into your WordPress real estate site.
Shortcode: [property_video]
Examples and Usage
Basic example – In the simplest form, the ‘property_video’ shortcode can be used to fetch videos related to a property listing by leveraging the ‘_listing_video’ custom field.
[property_video /]
Advanced examples
While the ‘property_video’ shortcode doesn’t support additional parameters in its current form, we can extend its functionality by modifying the PHP function. Let’s assume that we have added two parameters: ‘id’ and ‘size’. The ‘id’ parameter allows us to fetch a video for a specific property listing, and ‘size’ parameter can be used to define the video size.
function property_video_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => '',
'size' => '',
), $atts );
$id = $atts['id'];
$size = $atts['size'];
// Additional code to fetch and return the video based on $id and $size
return genesis_get_custom_field( '_listing_video' );
}
With the above modifications, we can now use the ‘property_video’ shortcode with ‘id’ and ‘size’ parameters. Here’s an example:
[property_video id="123" size="large" /]
In this example, the shortcode will fetch and display the video for the property listing with the ID ‘123’. The video size will be ‘large’.
PHP Function Code
In case you have difficulties debugging what causing issues with [property_video]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'property_video', array( $this, 'property_video_shortcode' ) );
Shortcode PHP function:
function property_video_shortcode( $atts ) {
return genesis_get_custom_field( '_listing_video' );
}
Code file location:
agentpress-listings/agentpress-listings/includes/class-agentpress-listings.php
Conclusion
Now that you’ve learned how to embed the AgentPress Listings Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply