<nav class="site-footer-privacy-nav">
<?php
wp_nav_menu(
array(
'theme_location' => 'footer',
'menu_class' => 'site-footer-privacy',
'walker' => new Walker_Nav_Menu(),
)
);
?>
</nav>
Display logo in footer
<div class="footer-logo">
<?php if ( function_exists( 'the_custom_logo' ) ) {
the_custom_logo();
} ?>
</div>
Translate Delivery in Kadence Cart
document.addEventListener('DOMContentLoaded', () => {
function translateElement(el) {
if (
el.matches('.wc-block-components-totals-item__label') &&
el.textContent.trim() === 'Delivery'
) {
el.textContent = 'Szállítás';
}
if (el.matches('.wc-block-components-totals-shipping-address-summary')) {
el.innerHTML = el.innerHTML.replace(/^Delivers to/, 'Szállítva ide');
}
if (
el.matches('.wc-block-components-shipping-address-check') &&
el.textContent.trim() === 'Enter address to check delivery options'
) {
el.textContent =
'Add meg a címet a szállítási lehetőségek ellenőrzéséhez';
}
}
// Initial pass
document
.querySelectorAll(
'.wc-block-components-totals-item__label, .wc-block-components-totals-shipping-address-summary, .wc-block-components-shipping-address-check'
)
.forEach(translateElement);
// Observe only new nodes
new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
translateElement(node);
node
.querySelectorAll(
'.wc-block-components-totals-item__label, .wc-block-components-totals-shipping-address-summary, .wc-block-components-shipping-address-check'
)
.forEach(translateElement);
}
});
});
}).observe(document.body, { childList: true, subtree: true });
});
Shortcode template in block theme
<!-- wp:shortcode -->
[hello]
<!-- /wp:shortcode -->
Social Share

<div class="social-share-wrapper">
<h2><?php esc_html_e( 'Social share', 'frost' ); ?></h2>
<div class="social-share">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" target="_blank" class="facebook-share">
<img src="" alt="">
</a>
<a href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank" class="twitter-share">
<img src="" alt="">
</a>
<a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" class="linkedin-share">
<img src="" alt="">
</a>
<a href="mailto:?subject=<?php the_title(); ?>&body=<?php the_permalink(); ?>" target="_blank" class="email-share">
<img src="" alt="">
</a>
</div>
</div>
Full code with svg icons
<div class="social-share-wrapper">
<h2><?php esc_html_e( 'Social share', 'frost' ); ?></h2>
<div class="social-share">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" target="_blank" class="facebook-share">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64h98.2V334.2H109.4V256h52.8V222.3c0-87.1 39.4-127.5 125-127.5c16.2 0 44.2 3.2 55.7 6.4V172c-6-.6-16.5-1-29.6-1c-42 0-58.2 15.9-58.2 57.2V256h83.6l-14.4 78.2H255V480H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"/></svg>
</a>
<a href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank" class="twitter-share">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm297.1 84L257.3 234.6 379.4 396H283.8L209 298.1 123.3 396H75.8l111-126.9L69.7 116h98l67.7 89.5L313.6 116h47.5zM323.3 367.6L153.4 142.9H125.1L296.9 367.6h26.3z"/></svg>
</a>
<a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" class="linkedin-share">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"/></svg>
</a>
<a href="mailto:?subject=<?php the_title(); ?>&body=<?php the_permalink(); ?>" target="_blank" class="email-share">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM218 271.7L64.2 172.4C66 156.4 79.5 144 96 144l256 0c16.5 0 30 12.4 31.8 28.4L230 271.7c-1.8 1.2-3.9 1.8-6 1.8s-4.2-.6-6-1.8zm29.4 26.9L384 210.4 384 336c0 17.7-14.3 32-32 32L96 368c-17.7 0-32-14.3-32-32l0-125.6 136.6 88.2c7 4.5 15.1 6.9 23.4 6.9s16.4-2.4 23.4-6.9z"/></svg>
</a>
</div>
</div>
.social-share {
display: flex;
gap: 15px;
br {
display: none;
}
a {
text-decoration: none;
}
svg {
width: 30px;
}
}
ACF Embedded repeater
<div class="project-buttons">
<ul class="btn-list">
<?php
if( have_rows('project_type') ):
while( have_rows('project_type') ) : the_row();
$project_title = get_sub_field('project_type_title'); ?>
<h2 class="wp-block-heading"><strong><?= $project_title ?></strong></h2>
<?php if( have_rows('project_type_repeater') ):
while( have_rows('project_type_repeater') ) : the_row();
$pdf_title = get_sub_field('title');
$pdf_subtitle = get_sub_field('subtitle');
$pdf_file = get_sub_field('file'); ?>
<li class="btn-list-item">
<a class="btn-pdf" href="<?php echo esc_url($pdf_file); ?>" target="_blank" rel="noopener noreferrer">
<div class="btn-pdf-inner">
<h3 class="btn-pdf-title"><?php echo esc_html($pdf_title); ?></h3>
<p class="btn-pdf-subtitle"><?php echo esc_html($pdf_subtitle); ?></p>
</div>
</a>
</li>
<?php
endwhile;
endif;
endwhile;
endif;
?>
</ul>
</div>
PolyLang if statement
<?php
$currentlang = pll_current_language(); // Polylang függvénye
if ($currentlang == "hu") {
echo '<button>Kapcsolat</button>';
} else {
echo '<button>Contact</button>';
}
?>
Check current currency in WooCommerce Booster
// ==================================================
// CHECK CURRENT CURRENCY
// ==================================================
function wpflames_check_currency() {
if ( function_exists( 'get_woocommerce_currency' ) ) {
$current_currency = get_woocommerce_currency();
if ( 'EUR' === $current_currency ) {
echo 'EUR';
} else {
echo 'HUF';
}
}
}
add_shortcode('check_currency', 'wpflames_check_currency');
// ==================================================
// SET GLOBAL ECHACNGE RATE EUR-HUF ÁRFOLYAM
// ==================================================
function set_global_exchange_rate() {
global $eur_huf_exchange_rate;
$eur_huf_exchange_rate = 410;
}
add_action( 'init', 'set_global_exchange_rate' );
// ==================================================
// SET GLOBAL COD FEE AMOUNT - HUF
// ==================================================
function set_global_fee_amount_huf() {
global $cod_fee_amount_huf;
$cod_fee_amount_huf = 800;
}
add_action( 'init', 'set_global_fee_amount_huf' );
// ==================================================
// SET GLOBAL COD FEE AMOUNT - EUR
// ==================================================
function set_global_fee_amount_eur() {
global $cod_fee_amount_eur;
global $cod_fee_amount_huf;
global $eur_huf_exchange_rate;
// Ha 800 HUF az utánvét díj, és 1 EUR = 410 HUF:
$cod_fee_amount_eur = $cod_fee_amount_huf / $eur_huf_exchange_rate;
}
add_action( 'init', 'set_global_fee_amount_eur' );
// ==================================================
// ADD EXTRA FEE TO SPECIFIC PAYMENT GATEWAY => COD
// ==================================================
function add_checkout_fee_for_gateway() {
global $cod_fee_amount_huf, $cod_fee_amount_eur;
// Ellenőrizzük, melyik fizetési módot választotta a felhasználó
$chosen_gateway = WC()->session->chosen_payment_method;
// Csak akkor fut le, ha az utánvétes (COD) fizetési módot választották
if ( $chosen_gateway == 'cod' ) {
// Lekérdezzük az aktuálisan használt pénznemet
$current_currency = get_woocommerce_currency();
// A díj értékének meghatározása az éppen használt pénznem szerint
if ( 'EUR' === $current_currency ) {
$fee_amount = $cod_fee_amount_eur;
} else {
// Alapértelmezett esetben HUF
$fee_amount = $cod_fee_amount_huf;
}
// Hozzáadjuk a plusz díjat a kosárhoz
// A harmadik paraméter határozza meg, hogy adóköteles-e a díj (true/false)
WC()->cart->add_fee( __( 'Utánvét díja', 'woocommerce' ), $fee_amount, false );
}
}
add_action( 'woocommerce_cart_calculate_fees', 'add_checkout_fee_for_gateway' );
// Part 2: reload checkout on payment gateway change
function refresh_checkout_on_payment_methods_change(){
?>
<script type="text/javascript">
(function($){
$( 'form.checkout' ).on( 'change', 'input[name^="payment_method"]', function() {
$('body').trigger('update_checkout');
});
})(jQuery);
</script>
<?php
}
add_action( 'woocommerce_review_order_before_payment', 'refresh_checkout_on_payment_methods_change' );
ACF Group inside Group – Embedded ACF group
<?php if( have_rows('about') ): ?>
<?php while( have_rows('about') ): the_row(); ?>
<?php if( have_rows('about_left') ): ?>
<?php while( have_rows('about_left') ): the_row();
$about_image = get_sub_field('about_image');
$about_name = get_sub_field('about_name');
$about_text = get_sub_field('about_text');
?>
<figure class="about-figure">
<?php if ($about_image): ?>
<img class="about-image" src="<?= esc_url($about_image); ?>" alt="<?= esc_attr($about_name); ?>">
<?php endif; ?>
<figcaption class="about-figcaption">
<span class="about-figcaption-title"><?= esc_html($about_name); ?></span>
<span class="about-figcaption-text"><?= esc_html($about_text); ?></span>
</figcaption>
</figure>
<?php endwhile; ?>
<?php endif; ?>
<?php if( have_rows('about_right') ): ?>
<?php while( have_rows('about_right') ): the_row();
$about_title = get_sub_field('about_title');
$about_content_1 = get_sub_field('about_content_1');
$about_content_2 = get_sub_field('about_content_2');
$about_content_3 = get_sub_field('about_content_3');
?>
<div class="about-caption-wrapper">
<div class="about-caption">
<h2 class="heading-2"><?= esc_html($about_title); ?></h2>
<p class="about-caption-text"><?= esc_html($about_content_1); ?></p>
<p class="about-caption-text"><?= esc_html($about_content_2); ?></p>
<p class="about-caption-text"><?= esc_html($about_content_3); ?></p>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
ACF Group
<section class="section">
<div class="wrapper">
<?php if( have_rows('hero') ): ?>
<?php while( have_rows('hero') ): the_row();
$image = get_sub_field('image');
$title = get_sub_field('title');
$subtitle = get_sub_field('subtitle');
$text = get_sub_field('text');
?>
<div class="hero">
<figure class="hero-figure">
<img class="hero-figure-img" src="<?= $image ?>" alt="">
</figure>
<div class="hero-caption-wrapper">
<div class="hero-caption">
<h1 class="hero-caption-title">
<span class="hero-caption-title-heading"><?= $title ?></span>
<span class="hero-caption-title-text"><?= $subtitle ?></span>
</h1>
<p class="hero-caption-text"><?= $text ?></p>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</section>
Add Custom Link to WPAdminBar – WP Migrate
// =========================================================================
// Add Custom Link to WPAdminBar - WP Migrate
// =========================================================================
add_action('admin_bar_menu', function($wp_admin_bar) {
$wp_admin_bar->add_node([
'id' => 'wp_migrate_admin_bar_menu',
'title' => 'WP Migrate',
'href' => '/wp-admin/tools.php?page=wp-migrate-db-pro',
]);
}, 999);
NextJS
npm install next@latest react@latest react-dom@latest
npm run dev
Remove archive description on frontend
// =========================================================================
// Remove archive description from DOM
// =========================================================================
add_filter('get_the_archive_description', function ($description) {
if (!is_admin()) {
return ''; //
}
return $description;
});
// =========================================================================
// Remove archive description with display none
// =========================================================================
add_filter('get_the_archive_description', function ($description) {
if (is_admin()) {
return $description; // Admin felületen megjelenik
}
return '<div style="display:none;">' . $description . '</div>'; // Frontenden rejtett
});
Change single post comment section title
// =========================================================================
// Single post comment title
// =========================================================================
add_filter('comment_form_defaults', function($defaults) {
$defaults['title_reply'] = 'YOUR CUSTOM TITLE';
return $defaults;
});
Generate WordPress Block
npm install -g @wordpress/create-block
npx @wordpress/create-block block-name
ACF Options Page
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Header Settings',
'menu_title' => 'Header',
'parent_slug' => 'theme-general-settings',
));
acf_add_options_sub_page(array(
'page_title' => 'Theme Footer Settings',
'menu_title' => 'Footer',
'parent_slug' => 'theme-general-settings',
));
}
Gatsby clean
A gatsby clean
parancs a Gatsby projektben a cache és a generált fájlok törlésére szolgál. Konkrétan a következőket teszi:
1. Törli a cache-t
- A Gatsby által generált
.cache
könyvtár tartalmát törli. - Ez a könyvtár a build folyamat során létrehozott átmeneti adatokat tartalmazza (pl. GraphQL lekérdezések eredményei, képgenerálási adatok).
- Ha ez a cache megsérül vagy elavult, előfordulhatnak hibák vagy nem kívánt viselkedések. A
gatsby clean
segít ezeket megoldani.
2. Törli a public mappát
- Az összesített build fájlokat tartalmazó
public
könyvtárat is törli. - Ez a mappa a kész weboldal statikus fájljait (HTML, CSS, JS, képek) tartalmazza, amelyeket a build folyamat során hoz létre a Gatsby.
3. Új build alapok
- A következő build teljesen tiszta környezetben történik, újraépítve minden fájlt és adatot.
- Ez különösen akkor hasznos, ha váratlan viselkedést tapasztalsz, például helytelenül renderelt komponenseket vagy elavult adatokat.
Mikor érdemes futtatni?
- Cache probléma gyanúja esetén: Ha olyan hibát tapasztalsz, amely látszólag nem a kód változásai miatt következik be.
- Új függőségek vagy pluginok hozzáadása után: Ha új függőséget vagy Gatsby plugint adsz a projektedhez, és az nem működik megfelelően.
- Deploy hibák elkerülése érdekében: Ha biztos akarsz lenni abban, hogy a build folyamat teljesen tiszta.
Hogyan használod?
Egyszerűen futtasd a következő parancsot a terminálban a projekt gyökérkönyvtárában:
gatsby clean
Utána
A gatsby clean
után általában új buildet kell indítani:
gatsby develop
vagy
gatsby build
Ez biztosítja, hogy a törölt fájlokat és cache-t újra generálja a Gatsby.
Display Cover – Gatsby
gatsby-node.js
const path = require("path");
const { assignIds } = require("@webdeveducation/wp-block-tools");
exports.createPages = async ({ actions, graphql }) => {
const pageTemplate = path.resolve("src/templates/page.js");
const { createPage } = actions;
const { data } = await graphql(`
query AllPagesQuery {
allWpPage {
nodes {
databaseId
blocks
uri
}
}
}
`);
for (let i = 0; i < data.allWpPage.nodes.length; i++) {
const page = data.allWpPage.nodes[i];
let blocks = page.blocks;
blocks = assignIds(blocks);
createPage({
path: page.uri,
component: pageTemplate,
context: {
blocks,
},
});
}
};
page.js
import React from "react";
import { BlockRendererProvider } from "@webdeveducation/wp-block-tools";
const Page = (props) => {
console.log("Page props: ", props);
return <BlockRendererProvider allBlocks={props.pageContext.blocks} />;
};
export default Page;
Display props – Gatsby
gatsby-node.js
const path = require("path");
exports.createPages = async ({ actions, graphql }) => {
const pageTemplate = path.resolve("src/templates/page.js");
const { createPage } = actions;
const { data } = await graphql(`
query AllPagesQuery {
allWpPage {
nodes {
databaseId
blocks
uri
}
}
}
`);
for (let i = 0; i < data.allWpPage.nodes.length; i++) {
const page = data.allWpPage.nodes[i];
let blocks = page.blocks;
createPage({
path: page.uri,
component: pageTemplate,
context: {
blocks,
},
});
}
};
src/templates/page.js
import React from "react";
const Page = (props) => {
console.log("Page props: ", props);
return (
<div>
<p>This is page template</p>
</div>
);
};
export default Page;
Display Title – Gatsby
gatsby-node.js
const path = require("path");
exports.createPages = async ({ actions, graphql }) => {
const pageTemplate = path.resolve("src/templates/page.js");
const { createPage } = actions;
const { data } = await graphql(`
query AllPagesQuery {
allWpPage {
nodes {
databaseId
title
blocks
uri
}
}
}
`);
for (let i = 0; i < data.allWpPage.nodes.length; i++) {
const page = data.allWpPage.nodes[i];
createPage({
path: page.uri,
component: pageTemplate,
context: {
title: page.title,
},
});
}
};
src/templates/page.js
import React from "react";
const Page = ({ pageContext }) => {
const { title } = pageContext;
return (
<div>
<h1>{title}</h1>
<p>This is page template</p>
</div>
);
};
export default Page;