Tagged: 

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

    Hi there,

    I used Advanced Custom Fields Pro to make a new input field called ‘gravitygallerij’.
    I want it to show up on every new post I make on my Enfold site.
    I have the code below to do that but I have no idea where to put it.
    I tried pasting it in single.php but that didn’t do the trick.

    Can you please tell me which file to edit?

    Hope you can help me – with kind regards!

    <?php 
    
    $images = get_field('gallery');
    
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <a href="<?php echo $image['url']; ?>">
                         <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                    </a>
                    <p><?php echo $image['caption']; ?></p>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
    #822200

    Hey MulderMind,

    Unfortunately it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However if its really important for you to get this done, you can always hire a freelancer to do the job for you :)

    Best regards,
    Basilis

    #822838

    Hi Basilis,

    Thanks for the reply – it was really important for me to get it done.

    Luckely the guys over at AFC helped me out (really awesome) and it works now.
    They gave me code to add to single.php and the images I add to the custom field of my posts show up underneath the posts now.
    In case everyone else has the same wish, you can use the code James from ACF gave me below.

    With kind regards!

    `<?php
    //get the global post to access the post id
    global $post;
    $images = get_field(‘NAMEOFYOURGALLERYFIELD, $post->ID);

    if( $images ): ?>

    <?php endif; ?>

    #823615

    Hi,

    Great, glad you got help form ACF and thanks for sharing, much appreciated :-)

    Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

    #832097

    Hi Rikard,

    You can close it – thanks for your assistance

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Show AFC Gallery field in every new post’ is closed to new replies.