// WPML translate CPT 'immoble' archive title on es
function wpml_translate_cpt_archive_title($title)
{
if (apply_filters( 'wpml_current_language', null ) == 'es' && is_post_type_archive('immoble')) {
$title = __('Inmuebles', 'kadence-child');
}
return $title;
}
add_filter('get_the_archive_title', 'wpml_translate_cpt_archive_title', 100);
Categoria: Kadence
CSS per al Switcher de WPML
Integració a la capçalera de kadence theme
/* wpml */
.header-html .wpml-ls-legacy-list-horizontal.wpml-ls-statics-footer {
margin-bottom: 0;
}
.wpml-ls-item {
position: relative;
}
.wpml-ls-item .wpml-ls-link {
padding-left: calc(2em / 2);
padding-right: calc(2em / 2);
padding-top: 0.6em;
padding-bottom: 0.6em;
}
.wpml-ls-item.wpml-ls-current-language:after {
content: '';
width: 100%;
position: absolute;
bottom: 0px;
height: 2px;
right: 50%;
background: var(--global-palette1);
-webkit-transform: scale(0, 0) translate(-50%, 0);
transform: scale(0, 0) translate(-50%, 0);
transition: color .0s ease-in-out, -webkit-transform .2s ease-in-out;
transition: transform .2s ease-in-out, color .0s ease-in-out;
transition: transform .2s ease-in-out, color .0s ease-in-out, -webkit-transform .2s ease-in-out;
width: calc(100% - 2em);
transform: scale(1, 1) translate(50%, 0);
}
.transparent-header .wpml-ls-item.wpml-ls-current-language:after {
background: var(--global-palette9);
}
.wpml-ls-item.wpml-ls-current-language .wpml-ls-link {
color: var(--global-palette1);
}
/* Si posem el shortcode dins del menú mobile, sinó esborrar o no actua */
#mobile-drawer .wpml-ls-item.wpml-ls-current-language:after,
#mobile-drawer .mobile-html .wpml-ls-item.wpml-ls-current-language .wpml-ls-link {
color: var(--global-palette9);
}
Kadence css “fixings”
/*
* Kadence css “fixings”
*/
body {
text-wrap: pretty;
}
/* header mobile */
.drawer-content .site-header-item {
overflow-y: auto;
max-width: 90vh;
}
.mobile-navigation {
max-height: 100%;
}
/* forms */
.kb-adv-form-message.kb-adv-form-warning {
padding: 0.1em 1em;
}
/* media */
@media (max-width: 1024px) {
#block-8 figure {
margin: 0 auto;
}
}
/*
* End Kadence css “fixings”
*/
Copy/Paste del “Block Content”, que ha desaperegut en Kadence🤷🏻♂️
De moment, pots fer servir el block Dynamic HTML block:

One page links per Kadence
function highlightAnchorLinks() {
// Get the menu elements
const primaryMenu = document.getElementById('primary-menu');
const mobileMenu = document.getElementById('mobile-menu');
// Get all anchor links within the primary menu
const primaryAnchorLinks = primaryMenu.querySelectorAll('li > a[href*="#"]');
// Get all anchor links within the mobile menu
const mobileAnchorLinks = mobileMenu.querySelectorAll('li > a[href*="#"]');
// Function to extract the target ID from the href attribute
const extractTargetId = (href) => {
const hashIndex = href.indexOf('#');
return hashIndex !== -1 ? href.substring(hashIndex + 1) : null;
};
// Create an intersection observer instance for the primary menu
const primaryObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
const targetId = entry.target.getAttribute('id');
const listItem = primaryMenu.querySelector(`li > a[href$="#${targetId}"]`).parentNode;
if (entry.isIntersecting && entry.intersectionRatio >= 0.5) {
const activeListItem = primaryMenu.querySelector('.current-menu-item');
if (activeListItem) {
activeListItem.classList.remove('current-menu-item', 'current_page_item');
}
listItem.classList.add('current-menu-item', 'current_page_item');
} else {
listItem.classList.remove('current-menu-item', 'current_page_item');
}
});
}, { threshold: [0.5] });
// Create an intersection observer instance for the mobile menu
const mobileObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
const targetId = entry.target.getAttribute('id');
const listItem = mobileMenu.querySelector(`li > a[href$="#${targetId}"]`).parentNode;
if (entry.isIntersecting && entry.intersectionRatio >= 0.5) {
const activeListItem = mobileMenu.querySelector('.current-menu-item');
if (activeListItem) {
activeListItem.classList.remove('current-menu-item', 'current_page_item');
}
listItem.classList.add('current-menu-item', 'current_page_item');
} else {
listItem.classList.remove('current-menu-item', 'current_page_item');
}
});
}, { threshold: [0.5] });
// Observe each section for the primary menu
primaryAnchorLinks.forEach(anchorLink => {
const targetId = extractTargetId(anchorLink.getAttribute('href'));
const section = document.getElementById(targetId);
if (section) {
primaryObserver.observe(section);
}
});
// Observe each section for the mobile menu
mobileAnchorLinks.forEach(anchorLink => {
const targetId = extractTargetId(anchorLink.getAttribute('href'));
const section = document.getElementById(targetId);
if (section) {
mobileObserver.observe(section);
}
});
}
// Call the function when the DOM is fully loaded
document.addEventListener('DOMContentLoaded', highlightAnchorLinks);
Hooks portfolio block Kadence
/**
* Server rendering for Post Block Inner Loop
*
* @param array $attributes the block attributes.
*/
function kadence_blocks_pro_render_portfolio_block_loop( $attributes ) {
$image_align = ( isset( $attributes['alignImage'] ) && isset( $attributes['displayImage'] ) && true === $attributes['displayImage'] && has_post_thumbnail() ? $attributes['alignImage'] : 'none' );
echo '<div class="kb-blocks-portfolio-grid-item">';
do_action( 'kadence_blocks_portfolio_loop_start', $attributes );
echo '<div class="kb-blocks-portfolio-grid-item-inner-wrap kb-feat-image-align-' . esc_attr( $image_align ) . '">';
/**
* Kadence Blocks Portfolio Loop Start
*
* @hooked kb_blocks_pro_get_portfolio_image - 20
*/
do_action( 'kadence_blocks_portfolio_loop_image', $attributes );
echo '<div class="kb-portfolio-grid-item-inner">';
/**
* Kadence Blocks Portfolio before Hover content.
*
* @hooked kb_blocks_pro_portfolio_hover_link - 10
* @hooked kb_blocks_pro_portfolio_hover_divs - 20
*/
do_action( 'kadence_blocks_portfolio_loop_before_content', $attributes );
echo '<div class="kb-portfolio-content-item-inner">';
/**
* Kadence Blocks Portfolio Hover content.
*
* @hooked kb_blocks_pro_get_portfolio_lightbox - 20
* @hooked kb_blocks_pro_get_portfolio_title - 20
* @hooked kb_blocks_pro_get_portfolio_taxonomies - 30
* @hooked kb_blocks_pro_get_portfolio_excerpt - 40
*/
do_action( 'kadence_blocks_portfolio_loop_content_inner', $attributes );
echo '</div>';
echo '</div>';
echo '</div>';
do_action( 'kadence_blocks_portfolio_loop_end', $attributes );
echo '</div>';
}
Ruta: /wp-content/plugins/kadence-blocks-pro/dist/dynamicblocks/portfolio-grid-carousel.php
Llista de Hooks per la bloc de ‘Post Grid’ de Kadence Theme Pro
add_action( 'kadence_blocks_post_no_posts', array( $this, 'get_no_posts' ), 15 );
add_action( 'kadence_blocks_post_loop_header', array( $this, 'get_above_categories' ), 10 );
add_action( 'kadence_blocks_post_loop_start', array( $this, 'get_post_image' ), 20 );
add_action( 'kadence_blocks_post_loop_header', array( $this, 'get_post_title' ), 20 );
add_action( 'kadence_blocks_post_loop_header', array( $this, 'get_meta_area' ), 30 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_date' ), 10 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_modified_date' ), 12 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_author' ), 15 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_category' ), 20 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_comment' ), 25 );
add_action( 'kadence_blocks_post_loop_content', array( $this, 'get_post_excerpt' ), 20 );
add_action( 'kadence_blocks_post_loop_content', array( $this, 'get_post_read_more' ), 30 );
add_action( 'kadence_blocks_post_loop_footer_start', array( $this, 'get_post_footer_date' ), 10 );
add_action( 'kadence_blocks_post_loop_footer_start', array( $this, 'get_post_footer_categories' ), 15 );
add_action( 'kadence_blocks_post_loop_footer_start', array( $this, 'get_post_footer_tags' ), 20 );
add_action( 'kadence_blocks_post_loop_footer_end', array( $this, 'get_post_footer_author' ), 10 );
add_action( 'kadence_blocks_post_loop_footer_end', array( $this, 'get_post_footer_comments' ), 15 );
Ruta: /wp-content/plugins/kadence-blocks-pro/dist/dynamicblocks/class-kadence-blocks-pro-post-grid.php
Ex:
// add content on post grid block
add_action('kadence_blocks_post_loop_header', 'add_maquinaria_meta', 30);
function add_maquinaria_meta()
{
// si es CPT maquinaria
if (get_post_type( ) === 'maquina') {
$capacidad_de_carga = get_field('capacidad_de_carga');
if ($capacidad_de_carga) {
echo '<div class="capacidad-de-carga">' . $capacidad_de_carga . '</div>';
}
}
}