Skip to content

Commit

Permalink
Fix taxonomy feed urls not picked up by sermon manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Miljković committed Aug 22, 2018
1 parent 9cf2359 commit 4a6cde1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
17 changes: 17 additions & 0 deletions includes/sm-core-functions.php
Expand Up @@ -841,3 +841,20 @@ function set_service_type( $post_ID ) {
}

add_action( 'save_post', 'set_service_type', 99 );

/**
* Returns registered Sermon Manager's taxonomies.
*
* @return array
*
* @since 2.13.5
*/
function sm_get_taxonomies() {
return array(
'wpfc_preacher',
'wpfc_sermon_series',
'wpfc_sermon_topics',
'wpfc_bible_book',
'wpfc_service_type',
);
}
4 changes: 2 additions & 2 deletions includes/sm-podcast-functions.php
Expand Up @@ -34,9 +34,9 @@
* The view can be overridden by placing a file named "wpfc-podcast-feed.php" in your (child) theme.
*/
add_action( 'rss_tag_pre', function () {
global $post_type;
global $post_type, $taxonomy;

if ( 'wpfc_sermon' === $post_type ) {
if ( 'wpfc_sermon' === $post_type || in_array( $taxonomy, sm_get_taxonomies() ) ) {
$overridden_template = locate_template( 'wpfc-podcast-feed.php' );
if ( $overridden_template ) {
load_template( $overridden_template );
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Expand Up @@ -103,6 +103,9 @@ Visit the [plugin homepage](https://wpforchurch.com/wordpress-plugins/sermon-man
2. Sermon Files

## Changelog ##
### 2.13.5 ###
* Fix: Taxonomy feed URLs not picked up by Sermon Manager

### 2.13.4 ###
* Change: Update Plyr to latest
* Fix: Small bug in media seeking URL detection
Expand Down
15 changes: 15 additions & 0 deletions views/wpfc-podcast-feed.php
Expand Up @@ -7,6 +7,8 @@

defined( 'ABSPATH' ) or exit;

global $taxonomy, $term;

/**
* Create the query for sermons.
*/
Expand All @@ -32,6 +34,19 @@
),
);

/**
* If feed is being loaded via taxonomy feed URL, such as "https://www.example.com/service-type/service-type-slug"
*/
if ( $taxonomy && $term ) {
$args['tax_query'] = array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $term,
),
);
}

/**
* Allow filtering by taxonomies.
*
Expand Down

0 comments on commit 4a6cde1

Please sign in to comment.