• Resolved dazman88

    (@dazman88)


    Hi,

    Im trying to build custom post type which will output all player shortcode attributes wrapped in the player shortcode. Im using ACF to store and output attributes such as:
    feed_url
    apple_sub
    google_sub

    and so on,

    my issue is how to output these values into a short code. I have tried nesting acf shortcodes within the podcast player short code like this:

    [podcastplayer feed_url=”[acf field=”feed_url”]”] but it does not work, I get a “RSS Error: Please provide a valid URL” – I have checked that parsing the naked acf field shortcode [acf field=”feed_url”] does output the RSS feed correctly, so this is just an issue of nesting shortcodes, if that is even possible.

    Would like to know if there’s a way to get this working.

    Much appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author vedathemes

    (@vedathemes)

    Hi there,

    1. shortcodes within shortcodes will not work. WordPress does not support this.
    2. Podcast player does support custom field for feed URL. You just need to do following,

    [podcastplayer feed_url="acf_field_name"]

    3. subscription option does not support ACF field. However, we need some custom solution for this.

    Inform me for more help on this.

    Thanks,

    Plugin Author vedathemes

    (@vedathemes)

    Hi @dazman88 ,

    I have created a custom function for you to fetch spotify, apple and google links from ACF fields.

    1. Copy and paste following PHP function in code snippets free plugin. You can also paste it at the end of your theme’s function.php file but it is lot more complicated and unsafe.

    add_filter(
    	'podcast_player_shcode_display',
    	function( $args ) {
    		$temp = array(
    			'apple-sub'   => $args['apple-sub'],
    			'google-sub'  => $args['google-sub'],
    			'spotify-sub' => $args['spotify-sub'],
    		);
    
    		foreach ( $temp as $key => $val ) {
    			$scheme = strtolower( wp_parse_url( $val, PHP_URL_SCHEME ) );
    			if ( in_array( $scheme, array( 'http', 'https' ), true ) ) {
    				continue;
    			}
    			// Check if url has been provided in as a custom field.
    			$custom_keys = get_post_custom_keys();
    			if ( $custom_keys && in_array( $val, $custom_keys, true ) ) {
    				$murl = get_post_custom_values( $val );
    				$murl = is_array( $murl ) ? $murl[0] : $murl;
    
    				$scheme1 = strtolower( wp_parse_url( $murl, PHP_URL_SCHEME ) );
    				if ( in_array( $scheme1, array( 'http', 'https' ), true ) ) {
    					$args[ $key ] = wp_strip_all_tags( $murl );
    				}
    			}
    		}
    		return $args;
    	},
    	12
    );

    2. Now let’s assume your ACF field name are as follows, acf_url, acf_apple, acf_google, acf_spotify. You can create a shortcode like this,

    [podcastplayer feed_url="acf_url" spotify_sub="acf_spotify" google_sub="acf_google" apple_sub="acf_apple"]

    You need to use actual acf filed name here.

    Note: Using custom PHP code might break your site if pasted incorrectly. Please backup your site and use code snippet plugin to do it safely.

    Plugin Author vedathemes

    (@vedathemes)

    Hi @dazman88 ,

    Did the above solution work for you? Do you need any more help?

    Thanks,

    Plugin Author vedathemes

    (@vedathemes)

    Hi there,

    I hope the issue has been resolved. Therefore, I am closing the ticket. However, feel free to comment on this ticket or create a new ticket if you need any more help with podcast player.

    Thanks,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using ACF fields in player shortcode’ is closed to new replies.