Type: php
HypeBuy My Account Shortcode
function hype_my_account_shortcode() { if (!is_user_logged_in()) { return ‘ You must be logged in to view your account. ‘; } $current_user = wp_get_current_user(); $avatar = get_avatar($current_user->ID, 96); global $wpdb; $order_count = $wpdb->get_var($wpdb->prepare(“SELECT COUNT(*) FROM wp_orders WHERE user_id = %d”, $current_user->ID)); $recent_orders…Continue reading
indexing
function add_custom_meta_tags() { if (is_single()) { global $post; echo ‘‘.”\n”; echo ‘Continue reading
Open graph
// Add this to your theme’s functions.php file or a custom plugin // Disable AIOSEO Open Graph if you’re keeping another plugin/theme for it add_filter(‘aioseo_disable_opengraph’, ‘__return_true’); // If your theme generates Open Graph tags and you want to disable them…Continue reading
kindle
Why the 2024 Kindle Paperwhite Is the Best E‑Reader Yet Looking for your next e‑reader? Amazon’s 2024 Kindle Paperwhite series raises the bar with speedier performance, a crisper screen, and features that delight both casual readers and A‑listers alike. Disclosure:…Continue reading
TDI
Product order WooCommerce
// Force alphabetical sorting on all product pages add_action(‘woocommerce_product_query’, function($q) { if (is_shop() || is_product_category() || is_product_tag()) { $q->set(‘orderby’, ‘title’); $q->set(‘order’, ‘ASC’); } });Continue reading
Ngăn WP cắt ảnh
add_filter(‘intermediate_image_sizes_advanced’, function ($sizes) { $sizes = array( ‘thumbnail’ => $sizes[‘thumbnail’], // Giữ lại thumbnail ‘medium’ => $sizes[‘medium’], // Giữ lại medium //’medium_large’ => $sizes[‘medium_large’], // Giữ lại medium_large ‘large’ => $sizes[‘large’], // Giữ lại large //’1536×1536′ => $sizes[‘1536×1536′], // Giữ…Continue reading
Custom image sizes
add_theme_support( ‘post-thumbnails’); add_image_size( ‘image-480’, 480, 9999 ); add_image_size( ‘image-640’, 640, 9999 ); add_image_size( ‘image-720’, 720, 9999 ); add_image_size( ‘image-960’, 960, 9999 ); add_image_size( ‘image-1168’, 1168, 9999 ); add_image_size( ‘image-1440’, 1440, 9999 ); add_image_size( ‘image-1920’, 1920, 9999 ); function my_custom_sizes( $sizes…Continue reading
Custom Excerpt Length
add_filter(‘excerpt_length’, ‘custom_excerpt_length’, 999); function custom_excerpt_length($length) { return 20; // number of words. Default is 55. }Continue reading