How to use in template file?
-
Hi there,
I love this plugin! SO much!How can I implement it in one of my theme pages (it’s a Portfolio custom post type). I’ve used Advanced Custom Fields to add an “After” image item to the admin area of the Portfolio item, and I’m wanting to use the “Featured Image” as the “Before”.
I’m just having a bear of a time getting this to work. I’ve tried the following code in my template page, but nothing shows up:
<div class="twentytwenty-wrapper twentytwenty-horizontal"> <div class='twentytwenty twentytwenty-container' style="max-width: 100%; width: 490px; height: 490px;"> <img class="twentytwenty-before" style="clip: rect(0px, 490px, 495px, 0px);" src="<?php the_post_thumbnail(); ?>"> <?php $image = get_field('after'); if( !empty($image) ): ?> <img class="twentytwenty-after" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> <?php endif; ?> <div class="twentytwenty-overlay"> <div class="twentytwenty-before-label"></div> <div class="twentytwenty-after-label"></div> </div> <div class="twentytwenty-handle" style="left: 240px;"> <span class="twentytwenty-left-arrow"></span> <span class="twentytwenty-right-arrow"></span> </div> </div> </div>
Basically, I want to use this for the portfolio grid, as well as have it appear on the individual portfolio item page, along with the other information that’s already fine and dandy.
This is the Lounge theme (and yes, I’ve asked the Qode team for help on this as well but I haven’t heard back yet), and I’m working on a child-theme of that.
I guess basically I’m just asking if there’s a simple php call I could insert instead.
Thanks in advance.
~Laura
- The topic ‘How to use in template file?’ is closed to new replies.