• Resolved Mike Matenkosky

    (@hikinmike)


    Is it possible to display the series image when a user clicks on the specific series?

    I tried by editing my child theme’s taxonomy-wpfc_sermon_series.php file by adding this: <?php echo do_shortcode( '[sermon_images display="series"]' ); ?>. All that does is display ALL series images.

    Wouldn’t mind doing the same thing for the preacher too, but series is what I really need now.

    Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Mike Matenkosky

    (@hikinmike)

    I found a solution. I added this to my custom taxonomy-wpfc_sermon_series.php file:

    
    <?php $series_image = get_the_terms( get_the_ID(), 'wpfc_sermon_series' );
    
    	if ( $series_image ){?>
    
    		<?php if ( function_exists( 'render_sermon_image' ) ) foreach ( get_the_terms( get_the_ID(), 'wpfc_sermon_series' ) as $cat ) : ?>
    
    			<?php echo render_sermon_image( $cat->term_id, 'large' ); ?>
    				 
    		<?php endforeach; ?>
    
    	<?php }else{ ?>
    
    <?php } ?>
    

    Hope somebody else can use it too.

    Thread Starter Mike Matenkosky

    (@hikinmike)

    Everything was fine on my testing site (sub-domain of our site), but this does not work on our site.

    When I tried to add a series image from the Media Library a got this: Cannot use a scalar value as an array in /wordpress/wp-includes/media.php on line 2898. I uploaded a new image and that took care of that error.

    Using the code from the previous post, the series image displays the current sermon image instead.

    I’m back to the original question, unless I can find another solution.

    Thread Starter Mike Matenkosky

    (@hikinmike)

    In my testing site I didn’t add the Featured Images, so it WILL display the Series Image on the series page because there is no image. When you add the Feature Image it will display the last sermon’s image.

    At least I wasn’t losing my mind. Original question still stands.

    Hi Mike,

    Thank you for your patience, and for sharing knowledge. ??

    Okay, I have no idea how get_the_terms() worked in the first place. That function is used to get the assigned terms of a post (or sermon), which should not work at all in this user-case.

    Anyway, I am sorry, but I am not 100% sure what are you trying to accomplish, but I will gladly send the solution once I know what the problem actually is. ??

    So, can you please explain a bit what exactly are you trying to do? (screenshots and drawings are helpful too)

    My understanding so far: Since you are editing taxonomy-wpfc_sermon_series.php, you want series image(s?) to show up on that page somewhere. That file is used at displaying sermons that are assigned to specific series. I’m now not sure if you want one image to appear at the top (for example) of the current series, or to display the image next to the individual sermon, or something entirely else?

    Let’s get this sorted out and the solution will be quick. ??

    Thread Starter Mike Matenkosky

    (@hikinmike)

    I’ve been using a “home grown” sermon plugin I found online years ago (https://web.archive.org/web/20140226144952/https://ryanspilhaus.com/2011/04/wordpress-sermon-archives-custom-posts-taxonomies/) and edited to my tastes. To show the series images I used the plugin ‘Categories Images’ and ‘Blubrry PowerPress’ to export to iTunes.

    To be honest, I’m not a coder. Like most things I’ve learned I’m a ‘Jack of all trades, master of none’ type a guy. The code I’ve provided above was modified to “work” from my previous plugin(s). Our church merged last year and a recently decided to switch to an off the shelf plugin instead.

    This is a Photoshop Screenshot Render of what I’m talking about: https://faithcommunitybible.org/wordpress/wp-content/uploads/2017/11/fcbc-screenshot-series.jpg. If a user clicks on a specific series, it should display the series name AND that image along with all of the sermons from that series. Yes, I’m editing the taxonomy-wpfc_sermon_series.php.

    You can see the plugin live: https://faithcommunitybible.org/sermons/

    Hope this helps. After my minor stroke, communication isn’t my strong suit.

    Hello Mike, you explained it perfectly!

    Here you go, this code should work for you:

    add_filter( 'post_thumbnail_html', function ( $html, $post_ID, $post_thumbnail_id, $size ) {
    	if ( is_tax( 'wpfc_sermon_series' ) ) {
    		$html = apply_filters( 'sermon-images-list-the-terms', '', array(
    			'image_size'   => $size,
    			'taxonomy'     => 'wpfc_sermon_series',
    			'after'        => '',
    			'after_image'  => '',
    			'before'       => '',
    			'before_image' => ''
    		) );
    	}
    
    	return $html;
    }, 10, 4 );

    Please put it at the end of your theme’s functions.php or in taxonomy-wpfc_sermon_series.php.

    I hope that it will work straight away, but if it doesn’t – please reply and we will work on resolving the issue. ??

    Thread Starter Mike Matenkosky

    (@hikinmike)

    I tried that on our testing site and it changes the sermon image to the series image: https://sandbox.faithcommunitybible.org/sermons/series/1-john/

    Thread Starter Mike Matenkosky

    (@hikinmike)

    FWIW I’m using one of Justin Tadlock’s child themes. Might help if I posted my taxonomy-wpfc_sermon_series.php file:

    
    <?php 
    /* 
    * Taxonomy (Series) Archive 
    *
    **************************************/
    
    get_header(); // Loads the header.php template. ?>
    
    <main <?php hybrid_attr( 'content' ); ?>>
    
    	<div class="wrap">
    
    		<?php if ( !is_front_page() && !is_singular() && !is_404() ) : // If viewing a multi-post page ?>
    		
    		<?php locate_template( array( 'misc/loop-meta.php' ), true ); // Loads the misc/loop-meta.php template. ?>		
    		
    		<div class="series-image">	
    
    			<?php add_filter( 'post_thumbnail_html', function ( $html, $post_ID, $post_thumbnail_id, $size ) {
    					if ( is_tax( 'wpfc_sermon_series' ) ) {
    						$html = apply_filters( 'sermon-images-list-the-terms', '', array(
    							'image_size'   => $size,
    							'taxonomy'     => 'wpfc_sermon_series',
    							'after'        => '',
    							'after_image'  => '',
    							'before'       => '',
    							'before_image' => ''
    						) );
    					}
    
    					return $html;
    				}, 10, 4 ); ?>	
    				
    		</div>		
    	
    	</div>				
    		
    	<?php endif; // End check for multi-post page. ?>	
    	
    	<?php if ( have_posts() ) : // Checks if any posts were found. ?>
    
    		<?php while ( have_posts() ) : // Begins the loop through found posts. ?>
    
    			<?php the_post(); // Loads the post data. ?>
    			
    			<article <?php hybrid_attr( 'post' ); ?>>
    			
    				<div class="featured-media">		
    				 
    					<?php get_the_image(
    						array(
    							'default' => hybrid_locate_theme_file( array( 'images/placeholder-550.jpg' ) ),
    							'size'    => 'fcbc-medium',
    							'width'   => '550',
    							'height'  => '413',
    							'scan'    => false,
    							'order'   => array( 'scan', 'featured', 'attachment', 'default' )
    						)
    					); ?>
    				
    				</div>	
    			
    				<header class="entry-header">
    			
    					<?php the_title( '<h2 ' . hybrid_get_attr( 'entry-title' ) . '><a href="' . get_permalink() . '" rel="bookmark" itemprop="url">', '</a></h2>' ); ?>
    
    				</header><!-- .entry-header -->					
    				
    				<div class="entry-content">
    				
    					<div class="date"><?php wpfc_sermon_date('F j, Y'); ?></div>
    					
    					<div class="preacher"><?php echo the_terms( $post->ID, 'wpfc_preacher', '', ', ', ' ' ); ?></div>							
    					
    				</div><!-- .entry-content -->
    				
    				<div class="entry-byline">						
    	
    					<?php edit_post_link(); ?>
    					
    				</div><!-- .entry-byline -->
    				
    			</article><!-- .entry -->		
    
    		<?php endwhile; // End found posts loop. ?>
    
    		<?php locate_template( array( 'misc/loop-nav.php' ), true ); // Loads the misc/loop-nav.php template. ?>
    
    	<?php else : // If no posts were found. ?>
    
    		<?php locate_template( array( 'content/error.php' ), true ); // Loads the content/error.php template. ?>
    
    	<?php endif; // End check for posts. ?>
    
    </main><!-- #content -->
    
    <?php get_footer(); // Loads the footer.php template. ?>
    
    Thread Starter Mike Matenkosky

    (@hikinmike)

    I have something that seems to work. Instead of what you posted, I added this to my theme’s taxonomy-wpfc_sermon_series.php file:

    
    <div class="series-image">	
    
    	<?php echo apply_filters( 'sermon-images-queried-term-image', '', array(
    				'image_size'   => 'large',
    				'taxonomy'     => 'wpfc_sermon_series'
    				)
    			);?>
    	
    </div>	
    
    

    If you see a better solution, I’m all ears. I haven’t added it to our live site, just the testing site for now.

    That’s a good solution, Mike!

    Glad you found it. I think that we can now mark this thread as resolved.

    Let us know if there’s anything else we can help with in future. ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Display Series Image on “Archive Taxonomy”’ is closed to new replies.