“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

Simple Table Of Contents

add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading

Open External Links in a New Tab

add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading

Scroll Progress Bar

add_action(‘wp_body_open’, function() { echo ‘ ‘; }); add_action(‘wp_head’, function() { echo ‘ ‘; }); add_action(‘wp_footer’, function() { echo ‘‘; });Continue reading