Plugin Author
Veda
(@vedathemes)
Hi there,
Thanks for using Podcast player.
Filtering episode using custom field is presently not possible with podcast player. However, there is a workaround which you may use,
1. Use text widget in Elementor and place podcast player shortcode in it. (How to add any shortcode in Elementor?)
2. Place following custom code at the end of your child theme’s functions.php file (Only if you are an experienced developer). Otherwise Use code snippet plugin to add custom code safely.
add_filter( 'podcast_player_shcode_display', function( $args ) {
$id = get_the_ID();
if ( ! $id || ( 'your_feed_url' !== $args['url'] ) ) {
return $args;
}
$filterby = get_post_meta( $id, 'your_custom_field_name', true );
$args['filterby'] = $filterby ? sanitize_text_field( $filterby ) : $args['filterby'];
return $args;
} );
3. In above code, replace your_feed_url with your actual feed URL (exactly as you put in the shortcode) and your_custom_field_name with your actual custom field name.
Important Note: Always backup your website before making PHP changes.
Inform if you need any other help with Podcast player.
Thanks,
Plugin Author
Veda
(@vedathemes)
Revised code. All other instructions remains the same as above,
add_filter( 'podcast_player_shcode_display', function( $args ) {
$id = get_the_ID();
if ( ! $id || ( 'your_feed_url' !== $args['url'] ) ) {
return $args;
}
$filterby = get_post_meta( $id, 'your_custom_field_name', true );
$args['filterby'] = $filterby ? sanitize_text_field( $filterby ) : $args['filterby'];
return $args;
} );
WOW!
Wonderful to read it all!
Very well detailed support !!!
I will try this for sure.
It is the suggestion to facilitate this in the PRO Version
😉 THX!
And it would also be interesting to enable these Dynamic TAGs for the fields:
https://i.postimg.cc/HxRH5xJ0/image.png
😀
I know I’m already abusing too much free support!
But…
All of my posts have a code at the end of the name, equivalent to the podcast code:
PODCAST – S03E02
(The URL is also: / PODCAST-S03E02)
Is it possible through this PHP to capture the last 6 digits of the post title instead of the Custom Field?
This would save me a few good hours filling in the custom field for each post.
(The full title may work, but it is certain that only the last 6 digits work best)
THX so Much!
Hi!
$ filterby = get_post_meta ($ post_id,' title ', true);
It does not work because the title is not a given goal, but
$ filterby = $ post-> post_title;
It also does not work, can you help me?
Thanks!
-
This reply was modified 4 years, 9 months ago by
ofmarconi.
its Works:
add_filter( 'podcast_player_shcode_display', function( $args ) {
$id = get_the_ID();
if ( ! $id || ( 'your_feed_url' !== $args['url'] ) ) {
return $args;
}
$filterby = get_the_title();
$args['filterby'] = $filterby ? sanitize_text_field( $filterby ) : $args['filterby'];
return $args;
} );
Easyyyyy