MemberPress: Add a Shortcode To Display the Number of Total Downloads for All Files

add_shortcode( ‘mepr-display-total-downloads’, function() { global $wpdb; $downloads_old = $wpdb->get_var( “SELECT SUM(download_count) FROM {$wpdb->prefix}mpdl_file_downloads” ); $downloads_new = $wpdb->get_var( “SELECT count(*) FROM {$wpdb->prefix}mpdl_file_stats” ); $downloads_old = isset( $downloads_old ) && $downloads_old != null ? $downloads_old : 0; $downloads_new = isset( $downloads_new )…Continue reading

Untitled Snippet

/** * Convert Uploaded Images to WebP Format * * This snippet converts uploaded images (JPEG, PNG, GIF) to WebP format * automatically in WordPress. Ideal for use in a theme’s functions.php file, * or with plugins like Code Snippets…Continue reading

change search url

function wpb_change_search_url() { if ( is_search() && ! empty( $_GET[‘s’] ) ) { wp_redirect( home_url( “/search/” ) . urlencode( get_query_var( ‘s’ ) ) ); exit(); } } add_action( ‘template_redirect’, ‘wpb_change_search_url’ );Continue reading

Plural Category Names – Helper and Archive Display

function get_term_plural_name($term_id, $taxonomy = ‘category’) { $plural = get_term_meta($term_id, ‘plural_name’, true); return $plural ?: get_term($term_id, $taxonomy)>name; } add_filter(‘get_the_terms’, function ($terms, $post_id, $taxonomy) { if (is_archive() || is_home()) { // Only for list contexts foreach ($terms as $term) { $plural =…Continue reading