Dominio Email & Office Sito web Sito WP Hosting Strumenti
Indietro
.com
$ 7.99 $ 26.99 /1 ° anno
.io
$ 9.99 $ 66.99 /1 ° anno
Indietro
Accedi
Pannello di controllo Webmail Editor Web E-commerce File Manager WordPress

Cos’è un tema child WordPress?

Un tema child WordPress è un ottimo parco giochi per i tuoi test

Un tema child è un’area del tuo sito web in cui è possibile modificare il tuo attuale tema. È come un parco giochi per i test. Naturalmente puoi apportare modifiche direttamente sul tuo tema WordPress, ma utilizzando un tema child ottimizzerai questo processo. Per esempio, supponiamo che tu decida di apportare delle nuove modifiche a file CSS (fogli di stile a cascata) o PHP (PHP: Hypertext Preprocessor) direttamente nel tuo tema. In questo caso, le modifiche verrebbero sovrascritte nel momento in cui aggiorni i tuoi temi, il che significa che in quel preciso istante, tutto ciò che hai cambiato nel tuo tema verrà perso.

vector

In breve

Glossary

Un tema child è fondamentalmente una copia del tema principale utilizzato su un sito web WordPress. Ti consente di personalizzare il tuo tema principale senza doverti preoccupare di perdere le tue personalizzazioni per gli aggiornamenti.

Ciò, naturalmente, non è auspicabile, visto che è tuo interesse salvare tutte le modifiche ogni volta che decidi di aggiornare il tuo tema; ed è qui che entra in gioco il tema child. Un tema child WordPress ti garantisce infatti, che tutte le tue modifiche rimangano intatte e ti permette persino di aggiungere funzioni ai tuoi temi.

Lavorare con i temi child

Se non sei solito modificare i file PHP e CSS, molto probabilmente non hai bisogno di un tema child. Tuttavia, in caso contrario, se le modifiche che apporti sono più di una semplice personalizzazione, troverai molto più semplice farlo con un tema child. Per esempio, se desideri aggiungere alcune tue funzioni, del codice PHP o scrivere un codice CSS complesso, ti conviene usare un tema child WordPress.

Se hai attivato un tema parent su WordPress, andando sul tuo editor, vedrai che puoi apportare un sacco di modifiche al tuo tema. Inoltre, avrai a disposizione opzioni e impostazioni infinite tra cui poter scegliere per effettuare modifiche e personalizzazioni.

Tuttavia, se hai attivato un tema child, aprendo il tuo editor, vedrai che sarà possibile apportare modifiche solo ai file PHP e CSS. Per poter lavorare su altre tipologie di file oltre ai PHP e CSS, dovrai selezionare i file che vuoi aggiungere al tuo tema child.

Creare un tema child WordPress

  • Vai sulla dashboard WordPress e seleziona Aggiungi nuovo plugin. Uno dei migliori plugin tema child è il plugin Child Theme Configurator.
  • Una volta attivato il plugin, lo troverai negli strumenti della tua dashboard.
  • Seleziona tema child negli strumenti, quindi seleziona un tema parent a tua scelta.
  • Una volta cliccato su Analizza, riceverai un messaggio in caso il tema possa essere utilizzato come tema child.
  • È possibile modificare il nome del tema, modificare le varie impostazioni, aggiungere tag al tema ecc. Una volta soddisfatto, puoi cliccare su Crea Nuovo tema child.

Per garantire che tu abbia creato il tema child WordPress con successo, vai su Aspetto e clicca sui Temi. Dovresti vedere il tema child presente, tema che devi ricordarti di attivare, in modo da disattivare anche il tema parent.

  • Una volta pronto per sperimentare e apportare modifiche, clicca su tema child sotto la voce strumenti.
  • Vai su File, da lì potrai visualizzare tutti i tuoi file. È possibile selezionare i file che desideri copiare nel tuo tema child.
  • Una volta tornato sull’editor, vedrai tutti i file che hai selezionato.

Se torni al tema parent, selezioni uno dei file che hai copiato sul tema child e decidi di eliminarlo, noterai che nulla di importante accadrà al tuo sito web. Questo perché tutti i file che hai selezionato sono stati copiati e memorizzati nel tuo tema child.

I temi child WordPress rappresentano una grande funzionalità da utilizzare quando si devono modificare file PHP e CSS. Inoltre, sono il modo migliore per assicurarti che nulla vada perso, così da non danneggiare il tuo sito web.

' html += '
' html += '' + ocKeys[locale].allPlans + '' html += '
' return html; } function ocGetLocale() { var localString = document.getElementsByTagName('html')[0].getAttribute("lang"); if (!localString) { return "en"; } if (localString.indexOf('-') === -1) { return localString; } return localString.split("-")[0] } function isInViewport(element) { var rect = element.getBoundingClientRect(); return ( rect.top >= 0 && rect.left >= 0 && rect.top <= (window.innerHeight || osShadowElement.documentElement.clientHeight) && rect.right <= (window.innerWidth || osShadowElement.documentElement.clientWidth) ); } function ocLogBuyClick(e) { if (!e.target.classList.contains("onecom_plans_cta_main")) { return; } var parent = e.target.parentNode.parentNode.parentNode.parentNode.parentNode; window.dataLayer.push({ event: "addToCart", ecommerce: { currencyCode: parent.getAttribute("data-currency"), add: { actionField: { list: document.getElementsByTagName('h1')[0].textContent }, products: [ { id: parent.getAttribute("data-title"), name: parent.getAttribute("data-title"), brand: "one.com", category: "pps", variant: parent.getAttribute("data-plan"), location: document.getElementsByTagName('h1')[0].textContent, price: parent.getAttribute("data-price"), quantity: 1 } ] } } }); } function ocLogTrackingInfo(e) { if ((e.getAttribute("data-marked") !== "1") || (!dataLayer)) { return; } e.removeAttribute("data-marked"); if (!e.getAttribute("data-title") || e.getAttribute("data-fresh") !== "1") { return; } console.info("push initiated") window.dataLayer.push({ id: e.getAttribute("data-title"), name: e.getAttribute("data-title"), brand: "one.com", category: "pps", variant: e.getAttribute("data-plan"), list: "/" + ocGetLocale() + "/", location: document.getElementsByTagName('h1')[0].textContent, price: e.getAttribute("data-price"), position: e.getAttribute("data-position") } ); e.setAttribute("data-fresh", "0"); } function ocSetImpression() { var plans = document.getElementsByClassName('oc-plan-container'); for (var i = 0; i < plans.length; i++) { if (isInViewport(plans[i])) { ocLogTrackingInfo(plans[i]); } } } function ocProductImpression(e) { var plans = document.getElementsByClassName('oc-plan-container'); for (var i = 0; i < plans.length; i++) { if (isInViewport(plans[i])) { plans[i].setAttribute("data-marked", "1"); ocTimeout = setTimeout(ocSetImpression, 2000) } } } /* var headingTag = window.location.hash.substr(1); if(headingTag.length > 0){ console.log(headingTag); osShadowElement.querySelector('#'+headingTag).scrollIntoView(); } */ //frontpage function scrollSmooth() { var elmntToView = osShadowElement.querySelector("#oc-plansandprices"); elmntToView.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); } const rightBtn = osShadowElement.querySelector('#right-button'); const leftBtn = osShadowElement.querySelector('#left-button'); if (rightBtn && leftBtn) { rightBtn.addEventListener("click", function (event) { const conent = osShadowElement.querySelector('#content'); conent.scrollLeft += 100; event.preventDefault(); let activeElement = osShadowElement.querySelector(".banner-thumb.active"); if (osShadowElement.querySelector(".banner-menu li:last-child").classList.contains('active')) { osShadowElement.querySelector(".banner-menu li:first-child").click(); } else { if (activeElement.nextElementSibling) { activeElement.nextElementSibling.click(); } } }); leftBtn.addEventListener("click", function (event) { const conent = osShadowElement.querySelector('#content'); conent.scrollLeft -= 100; event.preventDefault(); let activeElement = osShadowElement.querySelector(".banner-thumb.active"); if (osShadowElement.querySelector(".banner-menu li:first-child").classList.contains('active')) { osShadowElement.querySelector(".banner-menu li:last-child").click(); } else { if (activeElement.previousElementSibling) { activeElement.previousElementSibling.click(); } } }); } function nextSlide(thumbClass) { if (thumbClass.length > 0) { var elements = osShadowElement.querySelectorAll(".banner-section"); for (var i = 0, len = elements.length; i < len; i++) { elements[i].style.display = "none"; } var elements = osShadowElement.querySelectorAll(".banner-thumb"); for (var i = 0, len = elements.length; i < len; i++) { elements[i].classList.remove("active"); } var elmntToView = osShadowElement.querySelector('.banner-section-' + thumbClass); elmntToView.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest" }); var menuClicked = osShadowElement.querySelector('.banner-thumb-' + thumbClass); menuClicked.classList.add("active"); menuClicked.scrollIntoView(); osShadowElement.querySelector('.banner-section-' + thumbClass).style.display = "block"; } } const accordionTitlesSuccess = osShadowElement.querySelectorAll(".success-steps-col"); accordionTitlesSuccess.forEach((accordionTitle) => { accordionTitle.addEventListener("click", () => { if (accordionTitle.classList.contains("active")) { accordionTitle.classList.remove("active"); } else { const accordionTitlesWithIsOpen = document.querySelectorAll(".success-steps-col"); accordionTitlesWithIsOpen.forEach((accordionTitleWithIsOpen) => { accordionTitleWithIsOpen.classList.remove("active"); }); accordionTitle.classList.add("active"); } }); }); const accordionTitlesFaq = osShadowElement.querySelectorAll(".faq-col"); accordionTitlesFaq.forEach((accordionTitle) => { accordionTitle.addEventListener("click", () => { if (accordionTitle.classList.contains("active")) { accordionTitle.classList.remove("active"); } else { const accordionTitlesWithIsOpen = document.querySelectorAll(".faq-col"); accordionTitlesWithIsOpen.forEach((accordionTitleWithIsOpen) => { accordionTitleWithIsOpen.classList.remove("active"); }); accordionTitle.classList.add("active"); } }); }); (function () { slide('right'); })(); /***script to call APIs starts here**/ function checkStatus(response) { if (response.status >= 200 && response.status < 300) { return Promise.resolve(response); } else { return Promise.reject(new Error(response.statusText)); } } function parseJson(response) { return response.json(); } function niceRounding(stringDigit) { var lastDigit = stringDigit.at(-1); if (lastDigit == 8) { stringDigit = stringDigit.replace(/.$/, "9"); } return stringDigit; } /***script to call APIs ends here**/ /**Glosssary page***/ function scrollSmoothGlossary(alphabet) { var alphaList = osShadowElement.querySelectorAll(".alphabet-list"); for (let i = 0; i < alphaList.length; i++) { alphaList[i].classList.remove("active"); } var activeAlpha = osShadowElement.querySelector(".alpha-" + alphabet); activeAlpha.classList.add("active"); var elmntToView = osShadowElement.querySelector("#div-" + alphabet); //elmntToView.scrollTop = elmntToView.scrollHeight; elmntToView.scrollIntoView({ behavior: "smooth" }); //elmntToView.scrollTop(elmntToView.scrollHeight); } /**searching**/ const $search = osShadowElement.getElementById('search-glossary'); if ($search) { $search.addEventListener('input', (event) => { const searchText = event.target.value; const regex = new RegExp(searchText, 'gi'); const noSearchDiv = osShadowElement.querySelector(".no-glossary-search-found"); const itemList = osShadowElement.querySelectorAll(".oc-glossary-item-articles"); //const articleList = osShadowElement.querySelectorAll(".item-article"); var mainCount = 0; for (let j = 0; j < itemList.length; j++) { var articleList = itemList[j].querySelectorAll(".item-article"); var countDisplayBlock = 0; for (let i = 0; i < articleList.length; i++) { var h3 = articleList[i].getElementsByTagName("a")[0]; var text = h3.innerHTML; text = text.replace(/(|<\/mark>)/gim, ''); const newText = text.replace(regex, '$&'); h3.innerHTML = newText; if (text !== newText) { articleList[i].style.display = "flex"; countDisplayBlock++; } else { articleList[i].style.display = "none"; } } if (countDisplayBlock === 0) { itemList[j].parentNode.parentNode.style.display = "none"; } else { itemList[j].parentNode.parentNode.style.display = "flex"; mainCount++; } } if (mainCount === 0) { noSearchDiv.classList.remove("hidden"); } else { noSearchDiv.classList.add("hidden"); } }); } var select = osShadowElement.getElementById('alphabet-mobile-select'); if (select) { select.onchange = function () { var alphabet = this.options[this.selectedIndex].value; this.options[this.selectedIndex].classList.add('active'); scrollSmoothGlossary(alphabet); //var elmntToView = osShadowElement.querySelector("#" + alphabet); //elmntToView.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"}); }; } var glossaryHeader = osShadowElement.getElementById("glossary-header"); var glossaryStickyHeader = osShadowElement.getElementById( "glossary-header-sticky" ); // Get the offset position of the navbar if (glossaryHeader) { var sticky = glossaryHeader.offsetTop; } var glossarySearch = osShadowElement.querySelector(".oc-glossary-search"); // Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position function stickyAlphabets() { if (window.pageYOffset > sticky) { glossaryHeader.classList.add("hidden"); glossaryStickyHeader.classList.remove("hidden"); glossaryStickyHeader.style.zIndex = "99999"; glossarySearch.classList.add("hidden"); } else { glossaryHeader.classList.remove("hidden"); glossaryStickyHeader.classList.add("hidden"); glossarySearch.classList.remove("hidden"); } } /** HIGHLIGHT ALPHABET NAVIGATION LINKS WHILE SCROLLING */ // cache the navigation list-items containing links var navigationLinks = osShadowElement.querySelectorAll('#glossary-header-sticky > .glossary-header-alphabets > ul > li'); // cache the alphabet sections var sections = osShadowElement.querySelectorAll('.oc-glossary-item > div > span.item-head'); // map each target section ID to the corresponding navigation list-items var sectionIdToNavigationLink = {}; for (var i = 0; i < sections.length; i++) { var id = sections[i].id; sectionIdToNavigationLink[id] = osShadowElement.querySelectorAll('#glossary-header-sticky > .glossary-header-alphabets > ul > li.alpha-' + id); } function getOffset(el) { var _x = 0; var _y = 0; while (el && !isNaN(el.offsetLeft) && !isNaN(el.offsetTop)) { _x += el.offsetLeft - el.scrollLeft; _y += el.offsetTop - el.scrollTop; el = el.offsetParent; } return { top: _y, left: _x }; } function highlightNavigation() { // get the current vertical position of the scroll bar var scrollPosition = window.pageYOffset || document.documentElement.scrollTop; // iterate the sections for (var i = sections.length - 1; i >= 0; i--) { var currentSection = sections[i]; // get the position of the section var sectionTop = getOffset(currentSection).top; // if the user has scrolled over the top of the section if (scrollPosition >= sectionTop - 250) { // get the section id var id = currentSection.id; // get the corresponding navigation link var navigationLink = sectionIdToNavigationLink[id]; // if the link is not active if (typeof navigationLink[0] !== 'undefined') { if (!navigationLink[0].classList.contains('active')) { // remove .active class from all the links for (i = 0; i < navigationLinks.length; i++) { navigationLinks[i].className = navigationLinks[i].className.replace(/ active/, ''); } // add .active class to the current link navigationLink[0].className += (' active'); } } else { // remove .active class from all the links for (i = 0; i < navigationLinks.length; i++) { navigationLinks[i].className = navigationLinks[i].className.replace(/ active/, ''); } } // we have found our section, so we return false to exit the each loop return false; } } } if (glossaryHeader) { window.addEventListener('scroll', highlightNavigation); } /** Glossary page ends here**/ /** NL frontpage modification - version 2.0 **/ // Get the HTML element you need. const imageOverlay = osShadowElement.getElementById('testimonial-video-section-block-image-overlay'); const playButton = osShadowElement.getElementById('testimonial-video-section-block-play'); if (playButton) { var vidId = playButton.getAttribute("data"); // Add the event listener for the play button. playButton.addEventListener('click', play) } // The function that is called when the button is clicked. function play(e) { e.preventDefault(); let iframe_tag = osShadowElement.getElementById('ytplayer'); iframe_tag.setAttribute('src', 'https://www.youtube.com/embed/' + vidId + '?autoplay=1&enablejsapi=1&origin=http%3A%2F%2Flocalhost&widgetid=1'); imageOverlay.style.opacity = '0'; playButton.style.opacity = '0'; window.setTimeout(function () { playButton.style.display = 'none'; imageOverlay.style.display = 'none'; }, 800); // timed to match animation-duration } // Glossary page navigationbar issue fix Start let elemWebTopMenu = document.querySelector(".WebTop-Nav"); let elemWebTopSearch = document.querySelector(".MegaMenuAndSearchWrapper"); let elem = document.querySelector("#glossary-header-sticky"); if (elem && ( elemWebTopMenu || elemWebTopSearch ) ) { let rect = elem.getBoundingClientRect(); let elemTop = rect.top; let elemBottom = rect.bottom; let rectWebTop = elemWebTopMenu.getBoundingClientRect(); let elemTopWebTop = rectWebTop.top; let elemBottomWebTop = rectWebTop.bottom; let rectWebTopSearch = elemWebTopSearch.getBoundingClientRect(); let elemTopWebTopSearch = rectWebTopSearch.top; let elemBottomWebTopSearch = rectWebTopSearch.bottom; if ( ( elemBottomWebTopSearch >= elemTop ) || ( elemBottomWebTop >= elemTop ) ) { elem.style.zIndex = 200; } else { elem.style.zIndex = 0; } document.addEventListener('scroll', function() { let rect = elem.getBoundingClientRect(); let elemTop = rect.top; let elemBottom = rect.bottom; let rectWebTop = elemWebTopMenu.getBoundingClientRect(); let elemTopWebTop = rectWebTop.top; let elemBottomWebTop = rectWebTop.bottom; let rectWebTopSearch = elemWebTopSearch.getBoundingClientRect(); let elemTopWebTopSearch = rectWebTopSearch.top; let elemBottomWebTopSearch = rectWebTopSearch.bottom; if ( ( elemBottomWebTopSearch >= elemTop ) || ( elemBottomWebTop >= elemTop ) ) { elem.style.zIndex = 200; } else { elem.style.zIndex = 0; } }); } let glossaryNav = document.querySelector("#glossary-header-sticky"); let topSearchBarGloss = document.querySelector(".MegaMenuAndSearchWrapper"); let navSpacer = document.querySelector(".NavSpacer"); if ( glossaryNav && topSearchBarGloss) { topSearchBarGloss.style.position = 'static'; navSpacer.style.display = 'none'; } // Glossary page navigationbar issue fix End /******* Custom YouTube video embed js start *******/ let yt_thumb_wraps = document.querySelectorAll('.yt-video-wrapper.yt-play-icon'); if (yt_thumb_wraps) { yt_thumb_wraps.forEach(yt_thumb_wrap => { yt_thumb_wrap.addEventListener("click", function(event) { event.preventDefault(); let vid = event.target.dataset.vid; let yt_thumb = event.target; let vtitle = yt_thumb.getAttribute("title"); if(!vid){ yt_thumb = yt_thumb.querySelector('.yt-thumb-image'); vid = yt_thumb.dataset.vid; vtitle = yt_thumb.getAttribute("title"); } if(vid && yt_thumb){ let ytvideo = ''; let yt_thumb_wrap = yt_thumb.closest('.yt-video-wrapper.yt-play-icon'); yt_thumb_wrap.innerHTML = ytvideo; yt_thumb_wrap.classList.remove("yt-play-icon"); } }); }); } /******* Custom YouTube video embed js end *******/