This guide explains how to embed the ReservationKey search bar into a WordPress website built with Elementor. Because of how Elementor handles code, the process requires splitting the HTML, CSS, and JavaScript into separate parts. Once set up, the search bar allows guests to select check-in and check-out dates, enter the number of guests, and go directly to your ReservationKey booking page with the fields pre-filled.
The ReservationKey search widget normally works by copying a single block of HTML that includes both the layout and JavaScript functionality. However, in WordPress with Elementor, the built-in code widgets sometimes block inline JavaScript (such as onclick
events). To make it work, we need to separate the code into three pieces:
Normally, you can paste this code directly into an HTML block on a website. But for Elementor, we’ll need to separate it into different parts.
If the original code includes onclick
attributes (like onclick="searchDates()"
), remove those and replace them with a simple structure for the buttons and inputs. These interactions will be handled later by JavaScript.
<div id="rk-search">
<label>Check-in</label>
<input type="text" id="checkin">
<label>Check-out</label>
<input type="text" id="checkout">
<label>Guests</label>
<select id="numguests">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<button id="rk-search-btn">Search</button>
</div>
The example below shows common CSS adjustments used for spacing and responsiveness:
/* ReservationKey Search Bar Styling */
#rk-search {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
align-items: center;
}
#rk-search input,
#rk-search select {
padding: 6px 10px;
font-size: 14px;
}
#rk-search button {
background-color: #4a8bb5;
color: white;
padding: 8px 16px;
border: none;
border-radius: 6px;
cursor: pointer;
}
#rk-search button:hover {
background-color: #355f85;
}
If the guest dropdown looks too wide or misaligned, you can adjust its width in the CSS (for example, width: 80px;
).
Since Elementor doesn’t allow inline JavaScript inside HTML widgets, you’ll need to use a plugin such as “Header, Footer & Blocks for Elementor” or “Insert Headers and Footers”.
<script>
document.addEventListener('DOMContentLoaded', function() {
const searchBtn = document.getElementById('rk-search-btn');
if (searchBtn) {
searchBtn.addEventListener('click', function() {
const checkin = document.getElementById('checkin').value;
const checkout = document.getElementById('checkout').value;
const guests = document.getElementById('numguests').value;
const baseUrl = 'https://youraccount.reservationkey.com/availability.asp';
const url = baseUrl + '?startdate=' + checkin + '&enddate=' + checkout + '&numguests=' + guests;
window.location.href = url;
});
}
});
</script>
This code listens for clicks on the search button, gathers the date and guest values, and redirects users to your ReservationKey booking page with all details pre-filled.
If your widget includes a date picker, make sure to also include the JavaScript and CSS for it. Add them in the same header/footer section:
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<script>
$(function() {
$("#checkin, #checkout").datepicker({ dateFormat: "yy-mm-dd" });
});
</script>
To embed the ReservationKey search widget in a WordPress + Elementor site:
By splitting these three components, you can achieve a fully functional and styled search bar that integrates smoothly with Elementor’s system while maintaining ReservationKey’s booking functionality.
Tip: You can reuse the same JavaScript across all pages. Just copy the HTML widget to any section where you want a search bar to appear.