How to escape multiple attribute at once in WordPress?

The reason you escape attributes is to make sure that the values don’t have any characters that will break the HTML of the element. For example, if you didn’t escape: $attr=”foo”> <script>alert(“Bad!”);</script>”; Then this: <div class=”<?php echo $attr; ?>”></div> Would output: <div class=”foo”> <script>alert(“Bad!”);</script>”</div> Which would let the script run. So wp_kses_post() is completely wrong … Read more

What is the diferences between pure WordPress theme and Woocommerce theme? [closed]

There are no “WooCommerce themes”, only WordPress themes that eventually offer CSS styling for WooCommerce pages and layout elements, and, maybe, customize them by overwriting the WooCommerce templates. This is a good place to start: https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/theming/ Also, take a look at the “official” WooCommerce theme right from the creators: https://woocommerce.com/storefront/ Apart from these, the internet … Read more

Way to store featured image width and height in two separate variables?

You can always use the wp_get_additional_image_sizes() function to retrieve an image “size” (i.e. width, height, and the ‘crop’ option), like this: $image_sizes = wp_get_additional_image_sizes(); if ( isset( $image_sizes[‘slide_image’] ) ) { $size = $image_sizes[‘slide_image’]; var_dump( $size ); // Demo echo $size[‘width’]; // Demo } UPDATE In reply to your comment, i want to get the … Read more

Check if the image size is available and if not use ‘full’ image size

I don’t see why something like this wouldnt work! $med_post_thumb = get_the_post_thumbnail($post->ID, ‘medium_post_thumbnails’, array(‘class’ => ‘img-fluid’)). ‘</a></div>’; $full_post_thumb = get_the_post_thumbnail($post->ID, ‘FULL SIZE GOES HERE’, array(‘class’ => ‘img-fluid’)). ‘</a></div>’; if ($med_post_thumb == NULL) { echo $full_post_thumb; } else { echo $med_post_thumb; }