• I’ve seen versions of this dilemma solved here but none of the code in previous threads matches that of the theme I’m using, which is Total by WPexplorer.

    My website: http://www.drunkMall.com

    The homepage has infinite scroll so users can browse the contents of the entire site on one page if they choose. Currently, users who click a featured image, post title or “View Post” button are taken to an item’s full blog post, which contains an external link to the item’s purchase page.

    I want for users who click a featured image on the homepage to be taken directly (via external link) to the product purchase page. I know this can be done by adding a Custom Field to the “Edit Post” screen, which I’ve already done, and altering the theme’s code with a command to add a link using the info in the Custom Field. The last part is what I need help doing.

    The developer of my theme has told me which file needs to be altered. Here is the entire code in that file:

    <?php
    /**
     * Custom Post Type Entry Media
     *
     * @package Total WordPress theme
     * @subpackage Partials
     * @version 3.3.0
     *
     * @todo Add support for post featured video
     */
    
    // Exit if accessed directly
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    
    // Thumbnail args
    $args = apply_filters( 'wpex_'. get_post_type() .'_entry_thumbnail_args', array(
    	'size'          => 'full',
    	'alt'           => wpex_get_esc_title(),
    	'schema_markup' => true
    ) );
    
    // Get thumbnail
    $thumbnail = wpex_get_post_thumbnail( $args );
    
    // Display featured image
    if ( $thumbnail ) : ?>
    
    	<?php
    	// Get overlay style
    	$overlay = apply_filters( 'wpex_'. get_post_type() .'_entry_overlay_style', null ); ?>
    
    	<div class="blog-entry-media entry-media clr <?php echo wpex_overlay_classes( $overlay ); ?>">
    		<a href="<?php wpex_permalink(); ?>" title="<?php wpex_esc_title(); ?>" rel="bookmark" class="custom-posttype-entry-media-link <?php wpex_entry_image_animation_classes(); ?>">
    			<?php echo $thumbnail; ?>
    			<?php wpex_overlay( 'inside_link', $overlay ); ?>
    		</a>
    		<?php wpex_overlay( 'outside_link', $overlay ); ?>
    	</div><!-- cpt-entry-media -->
    
    <?php endif; ?>

    The name of the Custom Field I’ve created for entering the external link is ExternalURL. How do I wrap the featured image container with a link to the webpage entered into ExternalURL?

    I’m using a child theme.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Hyperlinking Featured Images to External Pages’ is closed to new replies.