Archives: Snippets
Untitled Snippet
Show Active Plugins First
add_filter(‘views_plugins’, function($views) { global $wp_list_table; if (!is_network_admin() && isset($wp_list_table->items)) { $all_plugins = $wp_list_table->items; $active_plugins = get_option(‘active_plugins’); $reordered_plugins = array(); // Add active plugins first foreach ($all_plugins as $plugin_file => $plugin_data) { if (in_array($plugin_file, $active_plugins)) { $reordered_plugins[$plugin_file] = $plugin_data; } }…Continue reading
Auto-Collapse Long Comments
add_filter( ‘comment_text’, function( $comment_content ) { $max_length = 100; // Set the maximum length of the comment to display without collapsing if ( strlen( $comment_content ) > $max_length ) { $short_content = substr( $comment_content, 0, $max_length ) . ‘…’; $full_content…Continue reading
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
Smooth Scrolling for Anchor Links
document.addEventListener(‘click’, function(e) { // Check if the clicked element is an anchor with href starting with ‘#’ if (e.target.tagName === ‘A’ && e.target.getAttribute(‘href’) && e.target.getAttribute(‘href’).startsWith(‘#’)) { e.preventDefault(); const targetId = e.target.getAttribute(‘href’).slice(1); // Remove the ‘#’ from the href const targetElement…Continue reading
Untitled Snippet
Houfy
<iframe style=”overflow:hidden;display:block;margin:0 auto;width:100%;max-width:400px;min-height:600px;border:none” src=”https://www.houfy.com/embed/Listing Number/pricing” frameborder=”0″></iframe>Continue reading
MemberPress: Add Bio Info To Account Page
function mepr_show_account_fields( $user ) { $bio = get_user_meta( $user->ID, ‘description’, true ); ?> Bio:Continue reading