How to Add Thumbnail to "entry-header" div class

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6858 Reply

    Greg

    Hi Ron,

    Using Asteroid theme and am looking to add a thumbnail to the post entry header. Position will be before the header text. Similar to the avatar placement in the comments.

    Is this done in the loop-blog.php? I’m struggling with the sample code. May I ask for your assistance?

    Great theme, really enjoy working with it. Thanks for your help.

    Greg

    #6859

    Ron
    Keymaster

    Is this done in the loop-blog.php?

    It depends on when your thumbnail should appear. The loop-blog.php is used when showing the “posts page” (multiple posts) while the loop-single.php is used for single pages.

    I’m struggling with the sample code.

    What sample code?

    On both loop-blog.php and loop-single.php the header text is added immediately after the opening <article> tag. You might want to add your image there.

    #6862

    Greg

    Thank you for your reply, it made me realize I was taking the wrong approach and not asking the right question.

    Ultimately, my goal is to have an icon image (in this case a favicon) align with and appear before the post title. Every time I create a new post I need the ability to drop the img src url (into a widget? custom field?) and have the icon spit out.

    What is the best approach towards this functionally? I can’t discern the most optimal between custom widget or custom field. I’m definitely too novice.

    Appreciate you taking my questions.

    #6863

    Ron
    Keymaster

    I’d like to point out that this functionality is not really specific to my themes and is more about modifying core WP functions. You may get better luck asking on forums like these:
    https://wordpress.org/support/forum/themes-and-templates
    https://wordpress.org/support/forum/plugins-and-hacks

    For the “custom field” part, there’s already a plugin that could handle that:
    https://wordpress.org/plugins/advanced-custom-fields/

    For joining the content of the custom field to the post title, you could use the title filter. This is just a sample/pseudo code to show how it could be done.

    add_filter( 'the_title', 'ra_custom_post_title' );
    
    function ra_custom_post_title( $title ) {
    
       $custom_field = get_post_meta($post_id, $key, $single);
    
       if ( ! empty($custom_field) ) {
          $title = $custom_field . $title;
       }
    
       return $title;
    }

    Read more on https://codex.wordpress.org/Custom_Fields

    #6872

    Greg

    Thank you Ron, helpful resources to get started with.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: How to Add Thumbnail to "entry-header" div class
Your information: