well, where there’s a will, there’s a way. A few hours after posting this thread I figured out how to add the title of the post as the image title and alt tag.
Then a few days later (today) I figured out how to insert the actual alt tag of the post thumbnail image.
So here is what I have set up now.
1. The image title tag attribute pulls from the post title, the_title().
2. The image alt tag attribute pulls from the alt attribute of the post featured thumbnail image, _wp_attachment_image_alt.
Below is the code to replace in the plugin auto-excerpt-everywhere/auto-excerpt-everywhere.php
Go to your WordPress plugins page. Click the edit link next to the Auto Excerpt everywhere plugin. On the edit page find the function you see below.
function auto_excerpt($content) {
global $post;
$testomore = get_option("excerpt_everywhere_moretext");
$imgmore = get_option("excerpt_everywhere_moreimg");
$whatthumb = get_option("excerpt_everywhere_thumb");
$customclass = get_option("excerpt_everywhere_class");
$alignment=get_option("excerpt_everywhere_align"); if ($alignment=="none"){$alignment="";}
if ($whatthumb=="none"){ $thumb = ""; }
else {
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
$default_attr = array(
'class' => "attachment-".$whatthumb." ".$alignment." autoexcerpt_thumb ".$customclass,
'alt' => trim(strip_tags(strip_shortcodes( $attachment->post_excerpt ))),
'title' => trim(strip_tags(strip_shortcodes( $attachment->post_title ))),
);
$thumb=get_the_post_thumbnail($post->ID, $whatthumb,$default_attr);
}
}
change it to the following code. I will explain at the end what is going on.
function auto_excerpt($content) {
global $post;
$testomore = get_option("excerpt_everywhere_moretext");
$imgmore = get_option("excerpt_everywhere_moreimg");
$whatthumb = get_option("excerpt_everywhere_thumb");
$customclass = get_option("excerpt_everywhere_class");
$title = get_the_title();
$thumb_id = get_post_thumbnail_id($post->ID);
$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
$alignment=get_option("excerpt_everywhere_align"); if ($alignment=="none"){$alignment="";}
if ($whatthumb=="none"){ $thumb = ""; }
else {
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
$default_attr = array(
'class' => "attachment-".$whatthumb." ".$alignment." autoexcerpt_thumb ".$customclass,
'alt' => "".$alt."",
'title' => "".$title."",
);
$thumb=get_the_post_thumbnail($post->ID, $whatthumb,$default_attr);
}
}
so what was added are 3 new arrays
$title = get_the_title();
$thumb_id = get_post_thumbnail_id($post->ID);
$alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
then these two lines
'alt' => trim(strip_tags(strip_shortcodes( $attachment->post_excerpt ))),
'title' => trim(strip_tags(strip_shortcodes( $attachment->post_title ))),
were changed to the following
'alt' => "".$alt."",
'title' => "".$title."",
It’s simple. I don’t understand why the author of the plugin didn’t do this.
The only thing you have to make sure of is including a featured image on each post and setting it’s alt attribute to your main keyword.
It is fully working on my site https://instantpaydaynetworkreview.com
when you view the source you will see both the title and alt attributes are set.