Skip to content

Instantly share code, notes, and snippets.

View Nikschavan's full-sized avatar
🎯
Focusing

Nikhil Nikschavan

🎯
Focusing
View GitHub Profile
@Nikschavan
Nikschavan / woocommerce-remove-uncategorized-from-breadcrumb.php
Last active August 3, 2023 09:14
Remove Untitled category from the breadcrumb.
<?php // don't copy this line in your code.
/**
* Remove uncategorized from the WooCommerce breadcrumb.
*
* @param Array $crumbs Breadcrumb crumbs for WooCommerce breadcrumb.
* @return Array WooCommerce Breadcrumb crumbs with default category removed.
*/
function your_prefix_wc_remove_uncategorized_from_breadcrumb( $crumbs ) {
$category = get_option( 'default_product_cat' );
$caregory_link = get_category_link( $category );
@Nikschavan
Nikschavan / allow-html-tags-in-post-excerpt.php
Created February 27, 2018 06:38
Allow iframe in the WordPress post excerpt.
<?php // don't copy this line in your code.
function your_prefix_custom_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
//Retrieve the post content.
$text = get_the_content('');
//Delete all shortcode tags from the content.
@Nikschavan
Nikschavan / astra-single-post-navigation-same-category.php
Created March 13, 2018 11:33
Make single post navigation to get links for posts in same category - Astra theme - https://wpastra.com/
<?php
function your_prefix_single_post_navigation_same_category( $args ) {
$args[ 'in_same_term' ] = true;
return $args;
}
add_filter( 'astra_single_post_navigation', 'your_prefix_single_post_navigation_same_category' );
@Nikschavan
Nikschavan / astra-sidebar-before-content.css
Created April 2, 2018 10:14
Astra Theme - Move the sidebar before the content on mobile
@media (max-width: 768px) {
#primary {
order: 2;
}
#secondary {
order: 1;
}
.ast-container {
@Nikschavan
Nikschavan / astra-sidebar-before-content.css
Created April 2, 2018 10:14
Astra Theme - Move the sidebar before the content on mobile
@media (max-width: 768px) {
#primary {
order: 2;
}
#secondary {
order: 1;
}
.ast-container {
jQuery(document).on('ready', function(event) {
// Scroll smoothly to anchor
jQuery('a[href^="#"]').on('click', function(event) {
var target = jQuery(this.getAttribute('href'));
if( target.length ) {
event.preventDefault();
jQuery('html, body').stop().animate({
scrollTop: target.offset().top
}, 1000);
@Nikschavan
Nikschavan / astra-align-footer-always-bottom-of-page.php
Last active May 16, 2018 14:21
Align the footer always in at the bottom of the page even if the page content is less.
@Nikschavan
Nikschavan / dynamic-astra-customizer-options-update.php
Last active May 16, 2018 15:03
Astra Theme - Add 'Apply Now` button in the Header conditionally with a link to page with a form to apply.
<?php // don't copy this line in your file.
// Condition to check if this page requires `Apply Now` button.
if ( 1481 === get_the_id() ) {
your_prefix_setup_header_button_apply_now();
}
/**
* Setup filters for changing the values in the Astra Settings.
*/
@Nikschavan
Nikschavan / astra-disable-title-on-all-pages.php
Last active May 18, 2018 07:02
Disable title on all pages - Astra WordPress Theme
<?php // don't copy this line in your code
/**
* Disable title on all post types.
*/
function your_prefix_post_title() {
$post_types = array(
'post',
'page',
@Nikschavan
Nikschavan / astra-disable-featured-image-on-all-pages.php
Last active May 18, 2018 07:02
Disable featured images on all pages - Astra WordPress Theme