asked 9 years ago

Hi, how hard would it be to modify the Focus theme so that it would allow two images for each post: one to be displayed as featured image for the DW Focus news slider, and a different image for the post itself (to be shown when you click on it). Its because we are having to compromise graphically when both have to be the same image (e.g. we want the news slider one to have a big title under it, and in the post itself we don’t want the title, etc). Thanks

1 Answers
answered 9 years ago

To resolve this issue, you can use the Dynamic Featured Image plugin. After successful plugin activation go to add or edit page of post or page and you will notice a new meta box for second featured image. After adding featured images click publish or update to save your post along with your featured images.
To display the Dynamic Featured Image in the single post, you can open the wp-contentthemesdw-focuscontent-single.php file. Fine the line 20.
Replace the following code:

<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumbnail"><?php the_post_thumbnail(); ?></div>
<?php endif; ?>

With new code:

<?php if( class_exists('Dynamic_Featured_Image') ) {
             global $dynamic_featured_image;
             $featured_images = $dynamic_featured_image->get_featured_images( get_the_ID() );

            //You can now loop through the image to display them as required
            //For example
            foreach( $featured_images as $image ) {
                echo "<a href='{$image['full']}'>";
                    echo "<img src='{$image['full']}' alt='Dynamic Featured Image' />";
                echo "</a>";
         } ?>

Hope this helps !

Powered by DW Question & Answer Pro