Add image to header

This topic contains 3 replies, has 2 voices, and was last updated by  Olivier Cardoen 3 days ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7529

    Arthur
    Participant
    • 2 Posts
    @asutaroto

    How do I insert an image into the header of the post? Which file is this edited in? I tried to add an image using the ACF plugin, but failed.

    Insertion code

    <?php 
    
    $image = get_field('image');
    
    if( !empty($image) ): ?>
    
    	<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    
    <?php endif; ?>

    Thank you in advance for your help.

    #7533

    Olivier Cardoen
    Participant
    • 281 Posts
    @themosaurusrex

    Hi @asutaroto,

    The custom header cannot be customize that way but you may consider using the grimlock_breadcrumb action to add markups inside the header safely.

    Simply add the following code snippet to your website:

    /**
      * Display some image after the header title, subtitle and metadata.
      */
    add_action( 'grimlock_breadcrumb', 'gorgo_custom_grimlock_breadcrumb', 20, 1 );
    
    function gorgo_custom_grimlock_breadcrumb() {
    	// Replace the following bit by your custom code.
    	?>
    	<img src="http://placehold.it/200x200" alt="Your image">
    	<?php
    }

    To add this code snippet to your site, we recommend that you use a the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/). If you have never activated this plugin, please read the following post:

    Adding Custom PHP Without Changing Your Child Theme

    Please also note that we don’t provide any theme customization. So, you shouldn’t expect other snippets from us unless it’s to fix an issue or some kind of limitation stemming from our own codebase. We always try our best to help theme users whenever we can and usually only provide code snippets out of courtesy to prevent them from waiting for the next update.

    Regards,

    #7535

    Arthur
    Participant
    • 2 Posts
    @asutaroto

    Thank you very much:)

    #7536

    Olivier Cardoen
    Participant
    • 281 Posts
    @themosaurusrex

    You’re welcome. 🙂👍

    Best,

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Add image to header’ is closed to new replies.