Archives: Snippets
Limit Meta Description to 160 characters
add_filter( ‘aioseo_description’, ‘aioseo_filter_description’ ); function aioseo_filter_description( $description ) { if ( strlen($description) > 160 ) { $description = substr($description, 0, 159); } return $description; }Continue reading
Limit SEO Title to 60 characters
add_filter( ‘aioseo_title’, ‘aioseo_filter_title’ ); function aioseo_filter_title( $title ) { if ( strlen($title) > 60 ) { $title = substr($title, 0, 60); } return $title; }Continue reading
Recreate the aioseo_cache table
add_action( ‘init’, function() { if ( function_exists( ‘aioseo’ ) ) { aioseo()->preUpdates->createCacheTable(); } });Continue reading
Disable autogenerated shipping details schema for WooCommerce
add_filter( ‘aioseo_schema_woocommerce_shipping_disable’, ‘__return_true’ );Continue reading
تغيير عمله
/** * Change a currency symbol */ add_filter(‘woocommerce_currency_symbol’, ‘change_existing_currency_symbol’, 10, 2); function change_existing_currency_symbol( $currency_symbol, $currency ) { switch( $currency ) { case ‘مصري’: $currency_symbol = ‘جنيه’; break; } return $currency_symbol; }Continue reading
Fix LearnPress conflict that hides AIOSEO tabs on settings pages
add_filter( ‘learnpress/admin/can-load-assets/lp-admin’, ‘aioseoDontLoadLearnPress’, 10, 2 ); add_filter( ‘learnpress/admin/can-load-assets/lp-admin-notice’, ‘aioseoDontLoadLearnPress’, 10, 2 ); function aioseoDontLoadLearnPress( $canLoad, $currentPage ) { if ( false === strpos( $currentPage, ‘aioseo’ ) ) { return $canLoad; } return false; }Continue reading
Livrare 20kg plus
add_action( ‘woocommerce_after_shipping_rate’, ‘action_after_shipping_rate’, 20, 2 ); function action_after_shipping_rate ( $method, $index ) { // Targeting checkout page only: if( is_cart() ) return; // Exit on cart page if( ‘flat_rate:1’ === $method->id ) { echo __(“ Cheltuielile de livare nu sunt…Continue reading
Add Image Alt Text automatic
function add_alt_text_to_images( $html ) { // Check if the image has a title attribute if ( preg_match( ‘/(title=[“\’].*?[“\’])/’, $html, $matches ) ) { // Get the title $title = substr( $matches[0], 7, -1 ); // Check if the image has…Continue reading