• Resolved kraken2k

    (@kraken2k)


    I’m having issues with multiple featured images shown on single event page. I’m using child theme and this code to insert featured image to post and pages:

    add_filter('the_content', 'put_thumbnail_in_posting');
    function put_thumbnail_in_posting($content) {
    	global $post;
    	if ( has_post_thumbnail() && ( $post->post_type == 'post' || 'page' ) ) {
    		the_post_thumbnail( '', array( 'class' => 'post-thumbnail-style' ) );
    	}
    	return $content;
    }

    The problem is, that on single event page, there are three of them. I adjusted single-event.php (copeid to child theme as descriped in guide), and by commenting the line <?php echo tribe_event_featured_image( $event_id, 'full', false );

    removed one of those images. Second is a part of post, the thrid however is inserted a bit mysteriously. The code:

    			<!-- Event content -->
    			<?php do_action( 'tribe_events_single_event_before_the_content' ) ?>
    			<div class="tribe-events-single-event-description tribe-events-content">
    				<?php the_content(); ?>
    			</div>
    			<!-- .tribe-events-single-event-description -->
    			<?php do_action( 'tribe_events_single_event_after_the_content' ) ?>
    
    			<!-- Event meta -->

    results in the HTML code

          (code ommited)
          <!-- Event content -->
    						<div class="tribe-events-single-event-description tribe-events-content">
    				<img (one featured image)/><p>(event_description)</p>
    			</div>
    			<!-- .tribe-events-single-event-description -->
    			<img (second featured image)/><div class="tribe-events-cal-links">
          (code ommited)

    The unwanted (second) featured image is generated by the code (the image vanishes when I remove it, but I don’t want to miss te iCal nad Google links):

    do_action( 'tribe_events_single_event_after_the_content' )

    I searched for “tribe_events_single_event_after_the_content” source, but I don’t know where to search and Google did not help with it…

Viewing 1 replies (of 1 total)
  • Thread Starter kraken2k

    (@kraken2k)

    I identified the issue – since “the_content” is called twice, I had to modify the code for inserting the featured image – in case of “tribe_events” post, filter is used just once:

    add_filter('the_content', 'put_thumbnail_in_posting');
    function put_thumbnail_in_posting($content) {
    	global $post;
    	if ( has_post_thumbnail() && ( $post->post_type == 'post' || 'page' ) ) {
    		the_post_thumbnail( '', array( 'class' => 'post-thumbnail-style' ) );
    		if ($post->post_type == 'tribe_events') { 							
    			remove_filter('the_content', 'put_thumbnail_in_posting');		
    		}
    	}
    	
    	return $content;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Duplicated (tripled) featured image on single event page’ is closed to new replies.