Skip to content

Instantly share code, notes, and snippets.

@generatepress
generatepress / gist:38a3d4d0e3f1be118cac76937e4c92e6
Last active September 23, 2019 17:05
Move navigation search to the secondary navigation
add_action( 'after_setup_theme', function() {
remove_action( 'generate_inside_navigation', 'generate_navigation_search' );
remove_action( 'generate_inside_navigation', 'generate_mobile_menu_search_icon' );
add_action( 'generate_inside_secondary_navigation', 'generate_navigation_search' );
add_action( 'generate_inside_secondary_navigation', 'generate_mobile_menu_search_icon' );
remove_filter( 'wp_nav_menu_items', 'generate_menu_search_icon', 10, 2 );
} );
@generatepress
generatepress / gist:60b9235b43866e346320e11cf40bb054
Created March 21, 2017 16:28
Add smooth scroll to anchor links. Just add the "smooth" class to your links: <a class="smooth" href="#my-anchor">My Anchor</a>
<script>
jQuery(function($) {
$('a.smooth[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 500);
@generatepress
generatepress / gist:282078076cd8631c17717d5b8640c043
Last active May 15, 2023 22:00
Initiate the mobile header at your desired width. Change 768px to whatever you like.
@media( max-width: 768px ) {
.site-header,
#site-navigation,
#sticky-navigation {
display: none !important;
opacity: 0;
}
#mobile-header {
display: block !important;
@mikejolley
mikejolley / gist:1622323
Created January 16, 2012 18:54
WooCommerce - Change default catalog sort order
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby');
function custom_default_catalog_orderby() {
return 'date'; // Can also use title and price
}