Fading Page Transitions

document.addEventListener(“DOMContentLoaded”, function() { // Create and insert CSS styles for fade-in and fade-out const style = document.createElement(‘style’); style.innerHTML = ` .fade-out { opacity: 0; transition: opacity 0.5s ease-in-out; } .fade-in { opacity: 1; transition: opacity 0.5s ease-in-out; } `; document.head.appendChild(style);…Continue reading

Display Related Posts by Category

global $post; if ( ! empty( $post ) ) { $categories = get_the_category( $post->ID ); if ( $categories ) { $category_ids = array(); foreach ( $categories as $category ) { $category_ids[] = $category->term_id; } $query_args = array( ‘category__in’ => $category_ids,…Continue reading

“New” Badge for Recent Posts

add_filter( ‘the_title’, function ( $title, $id ) { if ( ! is_admin() && is_single( $id ) ) { $number_of_days = 7; $post_date = get_the_date( ‘U’, $id ); $current_date = current_time( ‘timestamp’ ); $date_diff = $current_date – $post_date; if ( $date_diff…Continue reading

Floating Social Media Icons

// Define social media links $facebook_link = ‘https://facebook.com/yourprofile’; $twitter_link = ‘https://twitter.com/yourprofile’; $instagram_link = ‘https://instagram.com/yourprofile’; $linkedin_link = ‘https://linkedin.com/in/yourprofile’; echo ‘ ‘;Continue reading

Social Share Buttons

$post_url = urlencode( get_permalink() ); $post_title = urlencode( get_the_title() ); $facebook_url = “https://www.facebook.com/sharer/sharer.php?u=$post_url”; $x_url = “https://twitter.com/intent/tweet?url=$post_url&text=$post_title”; $linkedin_url = “https://www.linkedin.com/shareArticle?mini=true&url=$post_url&title=$post_title”; $social_buttons = ‘ ‘; echo $social_buttons; // Styles for the social sharing buttons. echo ‘ ‘;Continue reading

FAQ Accordion

$faqs = [ [ ‘question’ => ‘What is your return policy?’, ‘answer’ => ‘Our return policy lasts 30 days. If 30 days have gone by since your purchase, unfortunately, we can’t offer you a refund or exchange.’ ], [ ‘question’…Continue reading

Disable Author Archives

// Return a 404 page for author pages if accessed directly. add_action( ‘template_redirect’, function () { if ( is_author() ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } ); // Remove the author links. add_filter( ‘author_link’, ‘__return_empty_string’, 1000…Continue reading

Add SEO-friendly Breadcrumbs

// You can also use this snippet as a shortcode for more control. global $post; if ( ! is_home() ) { echo ‘ ‘; echo ‘Home / ‘; if ( is_category() || is_single() ) { the_category( ‘ / ‘ );…Continue reading