Category Fallback Image

/** * Plugin Name: Category Thumbnail Fallback * Description: Use the category image as fallback when the post does not have a featured image */ class WPBCategoryThumbnailFallback { protected static $taxonomies = [‘category’]; protected $nonceId = ‘wpb_category_thumb_fallback_none’; protected $fieldId =…Continue reading

Display Reading Time

$reading_speed = 200; // 200 words per minute $content = get_post_field( ‘post_content’, get_the_id() ); $word_count = str_word_count( strip_tags( $content ) ); $reading_time = ceil( $word_count / $reading_speed ); echo ‘ Estimated reading time: ‘ . absint( $reading_time ) . ‘…Continue reading

Display the Last Updated Date

$u_time = get_the_time( ‘U’ ); $u_modified_time = get_the_modified_time( ‘U’ ); // Only display modified date if 24hrs have passed since the post was published. if ( $u_modified_time >= $u_time + 86400 ) { $updated_date = get_the_modified_time( ‘F jS, Y’ );…Continue reading

Child Support Calculator

function child_support_calculator_shortcode() { // Enqueue the JavaScript wp_enqueue_script(‘child-support-calculator’, get_template_directory_uri() . ‘/path-to-your-js-folder/child-support-calculator.js’, array(‘jquery’), ‘1.0.0’, true); ob_start(); include get_template_directory() . ‘/path-to-your-html-folder/child-support-form.html’; return ob_get_clean(); } add_shortcode(‘child_support_calculator’, ‘child_support_calculator_shortcode’); Javascript document.addEventListener(“DOMContentLoaded”, function() { document.getElementById(“childSupportForm”).addEventListener(“submit”, function(event) { event.preventDefault(); const grossIncome = parseFloat(document.getElementById(“grossIncome”).value); let numChildren = parseInt(document.getElementById(“numChildren”).value);…Continue reading

Display the Last Updated Date

$u_time = get_the_time( ‘U’ ); $u_modified_time = get_the_modified_time( ‘U’ ); // Only display modified date if 24hrs have passed since the post was published. if ( $u_modified_time >= $u_time + 86400 ) { $updated_date = get_the_modified_time( ‘F jS, Y’ );…Continue reading

Display the Last Updated Date (copy)

$u_time = get_the_time( ‘U’ ); $u_modified_time = get_the_modified_time( ‘U’ ); // Only display modified date if 24hrs have passed since the post was published. if ( $u_modified_time >= $u_time + 86400 ) { $updated_date = get_the_modified_time( ‘F jS, Y’ );…Continue reading