Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have been in the process of adding the link post format to the thematic theme via a child theme. To be honest, this is the first time I have done any sort of theme work with WordPress.

I have been able to change the title permalink to the link I am linking to and adding a symbol to the title so that there is a visual to someone to realize that there may be a different behavior. (Example post)

Should I be using thematic's filters to push out these changes to the theme or should I be using WordPress's? Also, how do I add a permalink in the RSS feed so people can still comment on my site (much like Daring Fireball)

I have been doing the following in functions.php:

/**
 * Override the post title logic
 */
function mikewillsthematic_thematic_postheader_posttitle() {
    if (has_post_format('link')) {
        $posttitle = '<h2 class="entry-title"><a href="';
        $posttitle .= get_post_meta( get_the_ID(), "post_format_data", true);
        $posttitle .= '" title="Direct link to article" rel="bookmark">';
        $posttitle .= '&#8734; ';
        $posttitle .= get_the_title();   
        $posttitle .= "</a></h2>\n";
    } else {
        // Handle other post types.
    }
    return $posttitle;
}
add_filter('thematic_postheader_posttitle', 'mikewillsthematic_thematic_postheader_posttitle');

/**
 * Override the RSS URL
 */
function mikewillsthematic_rss_permalink($permalink) {
    global $wp_query;
    if($url = get_post_meta($wp_query->post->ID, 'post_format_data', true)) {
        return $url;
    }
    return $permalink;
}
add_filter('the_permalink_rss', 'mikewillsthematic_rss_permalink');

/**
 * Override the RSS title
 */
function mikewillsthematic_rss_title($title) {

    if (has_post_format('link')) {
        $posttitle = '&#8734; ';
            $posttitle .= $title;
    } else 
        $posttitle = $title;

    return $posttitle;
}
add_filter('the_title_rss', 'mikewillsthematic_rss_title');

But I feel that this seems... excessive. Is there a better way?

share|improve this question
add comment

2 Answers

as a self-appointed thematic support guru, i can simplify your first filter:

/**
 * Override the post title logic for post format 'link'
 */
function mikewillsthematic_thematic_postheader_posttitle($posttitle) {
    if (has_post_format('link')) {
        $posttitle = '<h2 class="entry-title"><a href="';
        $posttitle .= get_post_meta( get_the_ID(), "post_format_data", true);
        $posttitle .= '" title="Direct link to article" rel="bookmark">';
        $posttitle .= '&#8734; ';
        $posttitle .= get_the_title();   
        $posttitle .= "</a></h2>\n";
    } 
    return $posttitle;
}
add_filter('thematic_postheader_posttitle', 'mikewillsthematic_thematic_postheader_posttitle');

you might also want to do a test for the presence of the meta URL before you put it into the link. i don't think your solution looks excessive. you want to change the post permalink in 3 places, so i'm not surprised that you need 3 filters. kind of wonder why that isn't default behavior for link formats, but i'm not versed enough in post formats to know why WP did it that way.

afaik you cannot filter the post title via WP. when you have a solution (or before) please post at the thematic forums:

share|improve this answer
    
Thanks for the feedback. I have fixed that code. I'll ask on the Thematic forums about the filters. –  Mike Wills Jan 26 '12 at 4:11
add comment
up vote 0 down vote accepted

I figured out the right search terms and found out how to add content to the RSS feed.

// Add permalink to RSS feed
function mikewillsthematic_postrss($content) {
    if(is_feed() && has_post_format('link')) 
    {
        $content = $content.'<p><a href="'.get_permalink().'">Permalink</a></p>'; 
    }
    else {
        $content = $content;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'mikewillsthematic_postrss');
add_filter('the_content', 'mikewillsthematic_postrss');
share|improve this answer
add comment

protected by Community May 8 '12 at 9:59

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.