Post reading time shortcode

function reading_time() { if ( empty( $post ) && isset( $GLOBALS[‘post’] ) ) { $post = $GLOBALS[‘post’]; $content = get_post_field( ‘post_content’, $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 260); if ($readingtime == 1) {…Continue reading

Shortcode in Nav Menu, Widgets, Sidebar

/** * Enable shortcodes for menu navigation. */ if ( ! has_filter( ‘wp_nav_menu’, ‘do_shortcode’ ) ) { add_filter( ‘wp_nav_menu’, ‘shortcode_unautop’ ); add_filter( ‘wp_nav_menu’, ‘do_shortcode’, 11 ); } /** * Enable shortcodes for widgets (footer, sidebar…). */ if ( ! has_filter(…Continue reading

MemberPress: Add Author Custom Bio Shortcode

function mpcs_author_custom_bio_shortcode( $atts ) { if( !isset( $atts[‘slug’] ) || empty( $atts[‘slug’] ) ) { return; } global $post; $field = get_user_meta( $post->post_author, $atts[‘slug’], true ); if( empty( $field ) ) { return; } return ‘ ‘ . sanitize_text_field( $field…Continue reading