• Resolved ofmarconi

    (@ofmarconi)


    Hello, how is everything?

    I would like to know if your plugin is compatible with ACF or Custom Fields.

    I want to use it with a Template in Elementor and I would like my Author to just fill in Custom Fields and that would filter which episodes will be shown.

    It would work like this:

    The post would talk about a specific podcast, the Author would just put the code “S05E23” in Custom Fields, that custom fields would fill the filter field (Show episodes only if title contains following).

    It is possible?

    Sorry for my bad English :S

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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;
    } );
    Thread Starter ofmarconi

    (@ofmarconi)

    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!

    Thread Starter ofmarconi

    (@ofmarconi)

    And it would also be interesting to enable these Dynamic TAGs for the fields:

    https://i.postimg.cc/HxRH5xJ0/image.png

    😀

    Thread Starter ofmarconi

    (@ofmarconi)

    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!

    Thread Starter ofmarconi

    (@ofmarconi)

    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.
    Thread Starter ofmarconi

    (@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

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘ACF or Custom Fields’ is closed to new replies.