The Support desk at Kadence Pro is very helpful; they offer custom coding for hooks, css and even custom php whenever they can, which is far above and beyond. To view hooks for Kadence Blocks, – try this list.

As a way of giving back to the KadenceWP community – especially those of us who create custom themes on their Kadence framework, we are recording the snippets here. We all know that most of the time when we get stuck, we quickly google to see if a snippet is available so we don’t have to reinvent the wheel.

Note: all of these are credit to Kadence developers.

Mega Menu

When creating a mega menu, we found that adding tabbed blocks within it wasn’t working. This has been reported the team and will likely be fixed soon. In the meantime here’s a quick snippet to overwrite the css and make tabs work again in the Mega Menu Block in Kadence Pro.

Tabs not working in Mega Menu, adjust your css like so:

/* Mega Menu tabs and button block */
.header-menu-container ul.menu>li.kadence-menu-mega-enabled>ul .wp-block-kadence-advancedbtn {
		justify-content: flex-end;
}
.header-menu-container ul.menu>li.kadence-menu-mega-enabled>ul .wp-block-kadence-advancedbtn a {
		width: 150px;
		justify-content: flex-end;
}
.header-menu-container ul.menu>li.kadence-menu-mega-enabled>ul .wp-block-kadence-tabs .kt-tabs-id_13a480-69 > .kt-tabs-title-list li .kt-tab-title {
    border-width: 0 0 6px;
	  border-color: transparent;
}
.header-menu-container ul.menu>li.kadence-menu-mega-enabled>ul .wp-block-kadence-tabs .kt-tabs-title-list li .kt-tab-title:hover,
.header-menu-container ul.menu>li.kadence-menu-mega-enabled>ul .wp-block-kadence-tabs .kt-tabs-title-list li.kt-tab-title-active .kt-tab-title {
    border-color: var(--global-palette1, #3182CE)!important;
}

Kadence Previous / Next Navigation

add_filter('kadence_pagination_args', function($args){
	$args['prev_text'] = '<span class="screen-reader-text">' . __( 'Previous Page', 'kadence' ) . '</span>' . Kadence\kadence()->get_icon( 'arrow-left', _x( 'Prev', 'previous set of archive results', 'kadence' ) ) . '';
	$args['next_text'] = '<span class="screen-reader-text">' . __( 'Next Page', 'kadence' ) . '</span>' . Kadence\kadence()->get_icon( 'arrow-right', _x( '', 'next set of archive results', 'kadence' ) );
	
	return $args;
});

Yoast Primary Category Display

/**
 * Get the Yoast primary category from its post meta value, and displays it, with HTML markup.
 * If there is no primary category set, it displays the first assigned category.
 * 
 * @param boolean $useCatLink Whether to link the category, if it exists
 * @return void
 */


//add to post grid block
add_action( 'kadence_blocks_post_loop_header', 'wpb_primary_cat', 19);
//add to singles
add_action( 'kadence_single_before_entry_title', 'wpb_primary_cat');




function wpb_primary_cat( $useCatLink = true ) {


	// Retrieves post categories
	$category = get_the_category();


	// If post has a category assigned.
	if ( $category ) {
		$category_display = '';
		$category_link = '';
		
		// Get post's 'Primary' category from post meta
		$yoast_primary_key = get_post_meta( get_the_id(), '_yoast_wpseo_primary_category', TRUE );


		if ( !empty($yoast_primary_key) )
		{
			$term = get_term( $yoast_primary_key );


			if ( is_wp_error($term) ) { 
				// Default to first category (not Yoast) if an error is returned
				$category_display = $category[0]->name;
				$category_link = get_category_link( $category[0]->term_id );
				$child = get_category($category[0]->term_id);
				$category_parent = get_category($child->parent);
			} else { 
				// Yoast's Primary category
				$category_display = $term->name;
				$category_link = get_category_link( $term->term_id );
				$child = get_category($category[0]->term_id);
				$category_parent = get_category($child->parent);
			}
		}
		else {
			// Default, display the first category in WP's list of assigned categories
			$category_display = $category[0]->name;
			$category_link = get_category_link( $category[0]->term_id );
			$child = get_category($category[0]->term_id);
			$category_parent = get_category($child->parent);
			
		}


		// Display category
		if ( !empty($category_display) ){
			if ( $useCatLink == true && !empty($category_link) ){
				echo '<span class="primary-post-category-link kt-blocks-above-categories">';
				echo '<a href="', esc_url($category_link),'" class="', esc_html_e($category_parent->name),' ', esc_html_e($category_display),'">', esc_html_e($category_display), '</a>';
				echo '</span>';
				
			} else 
				echo '<span class="primary-post-category kt-blocks-above-categoriess">', esc_html_e($category_display), '</span>';
			}
		}
	}

Show Navigation for Custom Post Types in Kadence Templates

add_filter( 'kadence_post_layout', 'kt_cpt_show_post_navigation', 99 );


function kt_cpt_show_post_navigation( $value ) {
    if( 'evergreen_posts' === get_post_type() ) { 
	   $value['navigation'] = 'show';
    }
    return $value;
}

New! Welcome-Email AI Agent

Optin-Welcome Series GPT

Cathy Mitchell

Single Mom, Volunteer, Lifelong Learner, Jesus Follower, Founder and CEO at WPBarista.