get_the_post_thumbnail() title and alt attributes not displaying

Turns out this was caused by the following custom theme filter in functions.php. Commenting out fixed the problem. function image_alt_tags($content) { global $post; preg_match_all(‘/<img (.*?)\/>/’, $content, $images); if (!is_null($images)) { foreach($images[1] as $index => $value) { if (!preg_match(‘/alt=/’, $value)) { $new_img = str_replace(‘<img’, ‘<img alt=”‘ . get_the_title() . ‘”‘, $images[0][$index]); $content = str_replace($images[0][$index], $new_img, $content); … Read more

How to change default home link title?

For some reason this code has been added: <h1 class=”entry-title”><?php echo the_title(); ?></h1> the_title will display the current posts title, you should replace this with what you actually want. If you wanted to remove this completely with no replacement just delete this line. Also, this doesn’t appear to be a link at all, just a … Read more

Display text if title in archive has specific word

You may use string comparison. I could illustrate a simple example code. It is assumed that the user with the following knowledge/experience PHP – understand what is variables, static value WordPress templates and how to modify them There are many ways to test string such as php string comparison strpos() (simple) php regular expression preg_match() … Read more

Remove text after a dot and a colon in Woocommerce product title

Try using following code: add_filter(‘the_title’, ‘mod_product__title’, 10, 2); function mod_product__title($title, $id) { if( is_product() ) { if(preg_match(‘/[^(:|.)]*/’, $title, $matches)){ return trim($matches[0]); }else{ return $title; } } return $title; } Here I’m using regex to match . or : . Regex will match only the first occurrence and return the text before it. Then I’m using … Read more