• Resolved more.than.obsidian

    (@morethanobsidian)


    Hello,

    I have noticed that when I inserted manually an img tag in the post title (as a manually inserted icon), the post title somehow appears doubled below the featured image on the latest posts page. This doubled entry becomes part of the image link.

    For example please see how the first post is displayed on this site:
    http://www.hauptfachleben.com/
    For the post “Icon test” you can see “Icon test”>” below the featured image.

    This happens only if I insert a img tag in the post title and when there is a featured image assigned to the post.

    Is there maybe a way to solve this problem?
    Thank you very much!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello more.than.obsidian,

    First what you are doing is wrong, you should not insert <img tags into post title area.

    Second this happens because we are using a alt=”Post Title” tag in featured images so when you insert a <img tags into post title you will get something like next:

    <a href="post url"><img src="img src" alt="<img src="img src"> Post Title"

    And as you can see everything is breaking.

    Anyway if you want still use your method than you need to edit next file:

    Open
    wp-content/themes/agama/framework/blog/small_thumbs/loop.php

    Next find on line 14:
    <img class="image_fade img-responsive image-grow" src="<?php echo agama_return_image_src('agama-blog-small'); ?>" alt="<?php the_title(); ?>">

    And remove next part of code from img tag:
    alt="<?php the_title(); ?>"

    This should resolve your issue.

    Best Regards

    Thread Starter more.than.obsidian

    (@morethanobsidian)

    Hello jerryscg,

    thank you so much for your swift answer and a hint of where the files are located. This is really helpful. I was also not aware that this is a bad practice trying to insert the image in the title. I want to try to keep the alt attribute in the images so that the search engines can still find my image acc. to my post content, so I have come up with a manual fix using meta:

    In the custom fields of posts or pages, create a custom field with the name of
    title-icon-tag (this name can be changed to how you like it)
    and with the value as
    <img src="http://ABC.com/icon01.png"/>.

    Go to the loop.php file, line 27, add this code:
    <?php echo get_post_meta($post->ID, 'title-icon-tag', true); ?>
    before the <?php the_title(); ?>.
    This shows the icon in front of the title in the latest posts page.

    Go to the single.php file, line 8, add same code above before the <?php the_title(); ?>.
    This shows the icon in front of the title in the single posts page.

    The bad side of this code is that this will be removed after each update. I’m not so sure how to do this in the child theme. This is the downside to the code but it is functioning well.

    The img URL can be replaced with an emoji. Simply copy-paste from a list of emoji into the value field.

    Thanks for sharing your solution, maybe i will implement some solution for title icon in some of next updates.

    Best Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post title appearing below featured image if image is inserted in the title’ is closed to new replies.