Hello.
I want to set the placeholder of the search box that appears after clicking the search button in Korean. It currently says ‘search posts, tags, and authors,’ but this is done through an iframe, and I’m not sure how to do it.
Thanks ![]()
See this previous post with the same feature request and the answers there:
Adjust SEARCH_PLACEHOLDER value, inject this js and you are set.
<script>
// Quick Ghost Search Placeholder Changer
const SEARCH_PLACEHOLDER='Your custom placeholder';
(function() {
function changeGhostSearchPlaceholder() {
document.querySelectorAll('iframe').forEach( item =>{
const inputs=item.contentWindow.document.body.querySelectorAll('input[placeholder]');
for (const input of inputs) {
if (input.placeholder==='Search posts, tags and authors') {
input.placeholder = SEARCH_PLACEHOLDER;
return true;
}
}
}
)
return false;
}
// Try immediately
changeGhostSearchPlaceholder();
// Set up observer for dynamic content
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes.length || mutation.type === 'attributes') {
changeGhostSearchPlaceholder();
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true ,
attributes: true,
attributeFilter: ['aria-label', 'placeholder']
});
// Also try on search button clicks
document.addEventListener('click', (e) => {
if (e.target.closest('button')?.ariaLabel==='Search this site') {
setTimeout(changeGhostSearchPlaceholder, 100);
}
});
})();
</script>
Hey @artursp , welcome to Ghost! Please be careful not to bump two year old threads. (It’s a super easy mistake to make, but watch out - that related posts section can be really old stuff.)
In the case of this specific thread, a much better solution would be to contribute a translation (as search is now fully localizable!), if you’re still seeing English. Here’s how! 🌐 i18n mega-issue · Issue #23361 · TryGhost/Ghost · GitHub
(At this point, ALL strings in Ghost should be translatable or translated. If a language you want is showing English, it’s probably because no one has yet contributed a full set of strings. We need help!)