### Example iframe HTML
Source: https://docs.mylistingtheme.com/article/embedding-an-iframe
This is an example of an iframe tag that can be used to embed content. Ensure the src attribute is correctly set.
```html
```
--------------------------------
### How to use a code snippet (PHP)
Source: https://docs.mylistingtheme.com/explore?pg=3
Learn how to implement custom PHP code snippets in your MyListing theme. This is useful for adding specific functionalities not covered by default theme options.
```php
'event_date',
'value' => date( 'Y-m-d H:i:s' ),
'compare' => '>=',
'type' => 'DATETIME',
),
);
return $args;
}
add_filter( 'mylisting/query-args/events', 'mylisting_hide_past_events' );
```
--------------------------------
### WooCommerce Notify Admin on User Registration
Source: https://docs.mylistingtheme.com/author/admin/page/4
This code snippet sends an email notification to the admin when a new user registers via WooCommerce. Ensure WooCommerce is installed and configured.
```php
add_action( 'woocommerce_created_customer', 'wc_notify_admin_on_new_user' );
function wc_notify_admin_on_new_user( $customer_id ) {
// Get the admin email address
$admin_email = get_option( 'admin_email' );
// Get the user object
$user = wc_get_user_by_id( $customer_id );
// Construct the email subject and body
$subject = sprintf( __( 'New User Registered: %s', 'woocommerce' ), $user->user_login );
$body = sprintf( __( 'A new user has registered on your site: %s', 'woocommerce' ), $user->user_login );
// Send the email notification
wp_mail( $admin_email, $subject, $body );
}
```
--------------------------------
### Add WhatsApp Quick Action Link
Source: https://docs.mylistingtheme.com/article/single-page-tab-cover-style-cover-details-and-quick-actions
Use this URL format to create a custom quick action that opens WhatsApp with a pre-filled phone number. Ensure the 'Whatsapp number' custom field is set up correctly in the 'Fields' tab.
```html
https://api.whatsapp.com/send?phone=[[whatsapp-number]]
```
--------------------------------
### Show main menu icons on desktop
Source: https://docs.mylistingtheme.com/explore?pg=4&sort=latest&type=article
Display main menu icons on desktop view. This snippet enhances navigation by visually representing menu items.
```php
add_filter( 'case27_header_desktop_menu_icons', '__return_true' );
```
--------------------------------
### HTML for Copy Link Button
Source: https://docs.mylistingtheme.com/article/add-copy-link-button-to-the-quick-actions-section
Add this HTML to create the 'Copy link' button within the Quick Actions settings. It uses a specific class for styling and a link to a placeholder ID.
```html
Copy link
```
--------------------------------
### Enable Main Menu Icons on Desktop
Source: https://docs.mylistingtheme.com/article/show-main-menu-icons-on-desktop
Use this CSS to display menu icons on desktop screens. Add this code to your theme's custom CSS section.
```css
@media only screen and (min-width : 1201px) {
ul.main-nav li a>i {
display: inline-block;
padding-right: 5px;
}
}
```
--------------------------------
### Prevent Skipping Checkout for Free Listing Packages
Source: https://docs.mylistingtheme.com/article/do-not-skip-checkout-for-free-0-listing-packages
Use this filter in your theme's functions.php file to ensure that users go through the checkout process for all listing packages, including free ones. This prevents users from bypassing checkout for $0 packages.
```php
add_filter( 'mylisting\packages\free\skip-checkout', '__return_false' );
```
--------------------------------
### Use PHP Snippet for Custom Functionality
Source: https://docs.mylistingtheme.com/explore?pg=3&sort=latest&type=article
This snippet demonstrates how to use PHP for custom theme modifications. Ensure you understand the implications before adding custom code.
```php
add_filter( 'case_sensitive_tax_query', '__return_true' );
```
```php
add_filter( 'mylisting_hide_past_events', '__return_true' );
```
```php
add_filter( 'mylisting_keep_expired_listings_accessible', '__return_true' );
```
```php
add_filter( 'mylisting_bulk_geolocate_listings', '__return_true' );
```
```php
add_filter( 'mylisting_disable_checkout_for_free_packages', '__return_true' );
```
```php
add_filter( 'mylisting_use_listing_cover_image_in_share_dialog', '__return_true' );
```
```php
add_filter( 'woocommerce_registration_needs_terms_and_conditions', '__return_true' );
```
```php
add_filter( 'mylisting_use_listing_cover_image_in_share_dialog', '__return_true' );
```
```php
add_filter( 'mylisting_disable_post_author_email_on_new_comments', '__return_true' );
```
```php
add_filter( 'mylisting_disable_short_addresses', '__return_true' );
```
```php
add_filter( 'woocommerce_notify_admin_on_user_registration', '__return_true' );
```
```php
add_filter( 'mylisting_enable_acf_custom_fields_page', '__return_true' );
```
```php
add_filter( 'mylisting_enable_free_listing_submission', '__return_true' );
```
```php
add_filter( 'mylisting_limit_description_field_characters', '__return_true' );
```
```php
add_filter( 'mylisting_format_listing_price', '__return_true' );
```
--------------------------------
### Add 'Copy link' button to 'Quick Actions'
Source: https://docs.mylistingtheme.com/explore?pg=4
Adds a 'Copy link' button to the 'Quick Actions' section of a listing. This snippet is useful for providing users with an easy way to share listing links.
```php
add_action( 'mylisting_quick_actions', function( $post_id ) {
$link = get_permalink( $post_id );
printf( ' %2$s', esc_url( $link ), esc_html__( 'Copy link', 'my-listing' ) );
}, 20 );
```
--------------------------------
### Bulk Geolocate Listings PHP Snippet
Source: https://docs.mylistingtheme.com/article/after-importing-listings-they-are-not-shown-in-explore-page
Add this snippet to your child theme's functions.php file. It hooks into the 'init' action and, when triggered by a specific URL parameter, iterates through listings that lack geolocation data and attempts to geolocate them using the MyListing geocoder. Ensure your Google Maps API is working and addresses are imported correctly.
```php
'job_listing',
'offset' => $offset,
'posts_per_page' => $next_data,
'post_status' => ['publish', 'private', 'expired'],
'meta_query' => [
'relation' => 'OR',
[ 'key' => 'geolocation_lat', 'value' => '' ],
[ 'key' => 'geolocation_long', 'value' => '' ],
[ 'key' => 'geolocation_lat', 'compare' => 'NOT EXISTS' ],
[ 'key' => 'geolocation_long', 'compare' => 'NOT EXISTS' ],
],
] );
printf(
"Fetching geolocation data from listing %d to %d
",
$offset + 1,
$offset + $next_data
);
flush();
ob_flush();
foreach ( $listings as $listing ) {
if ( ! ( $location = get_post_meta( $listing->ID, '_job_location', true ) ) ) {
printf( '
Skipping geolocation for listing #%d (missing address)
', $listing->ID ); continue; } $geocoded = mylisting()->geocoder()->save_location( $listing->ID, $location ); if ( $geocoded !== false ) { printf( 'Geolocation successful for listing #%d (%s)
', $listing->ID, $location ); continue; } printf( 'Failed to geolocate listing #%d (%s)
', $listing->ID, $location ); } $offset = ( ! $offset ) ? $next_data : $offset + $next_data; } while( ! empty( $listings ) ); exit('All listings are updated, you can close this window.'); }, 250 ); ``` -------------------------------- ### Add 'Copy link' button to Quick Actions Source: https://docs.mylistingtheme.com/explore?pg=4&sort=latest&type=article Add a 'Copy link' button to the 'Quick Actions' section of a listing. This snippet is useful for providing users with an easy way to share listing URLs. ```php add_action( 'mylisting/listing/quick-actions', function( $post_id ) { $link = get_permalink( $post_id ); if ( ! $link ) { return; } ?>