WP-for-Church / Sermon-Manager

Sermon Manager for WordPress is the #1 plugin for churches who want to manage their sermons easily and missionally.
https://wordpress.org/plugins/sermon-manager-for-wordpress/
GNU General Public License v2.0
44 stars 34 forks source link

How to get single preacher image for archives in php. #269

Open regiside opened 4 years ago

regiside commented 4 years ago

Hey guys, I just wanted to share something I came across while trying to display the preacher image in the wpfc_preacher taxomony archive view. I was originally displaying the preachers image using apply_filters( 'sermon-images-list-the-terms', '' ); like so:

if ( apply_filters( 'sermon-images-list-the-terms', '', array( 'taxonomy' => 'wpfc_preacher', ) )) : // get speaker image: print apply_filters( 'sermon-images-list-the-terms', '', array( 'image_size' => $size, 'taxonomy' => 'wpfc_preacher', 'after' => '', 'after_image' => '', 'before' => '', 'before_image' => '' ) );

Problem with that approach, is that if the top post has multiple preachers associated with it, multiple preachers images will be displayed even though you're in an archive for a specific preacher. I searched around the documentation for how to properly display a single speaker's image but couldn't find anything. I then ran across the plugin originally used to develop the taxonomy images functionality for Sermon Manager and thankfully found a solution that still works with in the modified SM code: `if ( apply_filters( 'sermon-images-queried-term-image', '', array( 'taxonomy' => 'wpfc_preacher', ) )) : // get speaker image:

                        print apply_filters( 'sermon-images-queried-term-image', '', array(
                            'image_size'   => $size,
                            'taxonomy'     => 'wpfc_preacher',
                            'after' => '',
                            'after_image' => '', 
                            'before' => '', 
                            'before_image' => ''
                        ) );`

Hope this info is helpful to someone. Let me know if there's a better way to get the single preacher image in an archive.

Platform

Sermon Manager Version: 2.15.17
WordPress Version: 5.3.2
PHP Version: 7.3.14