• Matt

    (@webmasterifcj)


    Hello guys,

    I was hoping to get some help. I have posts that have attached audio files to them. What I would like to do is extend the excerpt function to include something like this:

    function holylandmoments_comment_link() {
    	return ' <a class="read-more-link" href="'. get_permalink() . '">' . __( 'Comment on this show &raquo;', 'holylandmoments-show' ) . '</a> &nbsp;|&nbsp; <a class="read-more-link" href="'. wp_get_attachment_url() . '">' . __( 'Listen to this episode &raquo;', 'holylandmoments' ) . '</a>';
    }
    function holylandmoments_custom_excerpt_more( $output ) {
    	if ( has_excerpt() && in_category( _x('devotionals', 'devotionals category slug', 'holylandmoments') ) &&! is_attachment() ) {
    		$output .= holylandmoments_read_more_link();
    	}
    	else
    	if ( has_excerpt() && in_category( _x('shows', 'shows category slug', 'holylandmoments') ) && is_attachment() ) {
    		$output .= holylandmoments_comment_link();
    	}
    	else
    	if ( has_excerpt() && in_category( _x('podcasts', 'pocasts category slug', 'holylandmoments') ) &&! is_attachment() ) {
    		$output .= holylandmoments_listen_link();
    	}
    	return $output;
    }
    add_filter( 'get_the_excerpt', 'holylandmoments_custom_excerpt_more' );

    What I would like the end result be:

    Post Headline
    September 6, 2010 – 5:00 am
    This week marks the beginning of the High Holy Days—the most sacred time of the year for the Jewish people and among the most widely observed of all the holy days. I often wonder whether synagogues experience such high numbers because these days mark an opportunity for all Jews to wash their slate clean and begin life anew. And who, at one time or another, hasn’t truly desired an opportunity to do just that? Read more… | Listen to Audio file link

    This is my archive.php page

    Any help would do.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Matt

    (@webmasterifcj)

    I’m trying to get this link to look like this:

    Comment on this show >> | Listen to this show >>

    Where “Comment on this show >>” gets populated properly with it’s permalink.

    “Listen to this show >>” link should be populated with that posts ‘Listen Now’ custom field value.

    function holylandmoments_comment_link() {
    	return ' <a class="read-more-link" href="'. get_permalink() . '">' . __( 'Comment on this show &raquo;', 'holylandmoments-show' ) . '</a> &nbsp;|&nbsp; <a class="read-more-link" href="'. get_post_meta($post->ID, 'Listen Now',true); . '">' . __( 'Listen to this episode &raquo;', 'holylandmoments' ) . '</a>';
    }

    Problem is I don’t get the path to the custom field value of Listen Now to populate the second link… any ideas??

    Thanks

    Thread Starter Matt

    (@webmasterifcj)

    I’m sorry to bump, but has anyone else had this problem?

    Thread Starter Matt

    (@webmasterifcj)

    Okay I guess no one is having this same issue. I would like to implement this in order for my sites feed to be showcased on iTunes as a podcast.

    Thread Starter Matt

    (@webmasterifcj)

    Okay got it… I wasn’t setting the global var of $post so I needed to make that addition to my functions.php page like such:

    function holylandmoments_comment_link() {
    	global $post;
    	return ' <a class="read-more-link" href="'. get_permalink() . '">' . __( 'Comment on this show &raquo;', 'holylandmoments-show' ) . '</a> &nbsp; | &nbsp; <a class="read-more-link" href="'. get_post_meta($post->ID, 'Audio File', true) . '">' . __( 'Listen to this show &raquo;', 'holylandmoments-show' ) . '</a> ';
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can I add a link to an audio file for a post to its excerpt??’ is closed to new replies.