View functions.php
function custom_add_to_cart_message() { | |
$message = 'New message' ; | |
return $message; | |
} | |
add_filter( 'wc_add_to_cart_message_html', 'custom_add_to_cart_message' ); |
View get_alt_value_image_id_wordpress.txt
/** | |
* | |
* Get alt value of image by ID | |
* | |
*/ | |
alt="<?php echo get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); ?> |
View disable-gutenberg-wordpress-5
/** | |
* | |
* Disable Gutenberg Editor for all post types | |
* | |
*/ | |
// disable for posts | |
add_filter('use_block_editor_for_post', '__return_false', 10); | |
// disable for post types |
View execute-php-wp-widget.txt
/** | |
* | |
* Executing PHP code in WordPress text widget | |
* | |
*/ | |
function execute_php($html){ | |
if(strpos($html,"<"."?php")!==false){ | |
ob_start(); | |
eval("?".">".$html); |
View add-body-class-wp-posts-no-featured-image.txt
/** | |
* | |
* Add body class to posts without featured image | |
* | |
*/ | |
function add_body_class_no_featured_image( $classes ) { | |
if(is_single() && !has_post_thumbnail()) { | |
$classes[] = 'no-featured-image'; |