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'd like to filter out certain post formats from certain page templates. Specifically, I'd like to exclude link post types from the front page, so I can put them in a side bar, but still keep them in archive pages. I'd also like to exclude them from a variant of an RSS feed (but not all RSS feeds).

I know I can do this by editing the templates, but is there a way to do this via a plugin alone?

share|improve this question

1 Answer 1

Since you're going to be modifying either the Loop Query or the Loop output, I would recommend modifying the appropriate template files directly.

To filter out Posts with the "quote" Post Format, simply wrap your Loop output (inside of the if-have-posts-while-have-posts-the-post) with:

if ( ! has_post_format( 'quote' ) ) {
    // Loop output goes here
}

Then, in your sidebar, you would create a custom Loop, e.g.:

$linkpostargs = array(
    'tax_query' => array(
        'taxonomy' => 'post_format',
        'field'    => 'slug',
        'terms'    => array( 'post-format-link' ),
        'operator' => 'IN'
    )
);
$link_posts = get_posts( $linkpostargs );

foreach ( $link_posts as $link_post ) {
    // Custom Loop output goes here
}

(H/T Michael Fields for the query args)

I honestly don't know how you'd replicate this functionality using a Plugin alone.

share|improve this answer
    
This sounds like what I needed, Chip. I'll experiment with this shortly. I've seen plugins that allow you to exclude widets from certain templates through UI alone, and thought there might be similar filter hooks in place in other parts of the engine that allowed this kind of behavior for post formats too. I'll accept the answer here if nobody else points out a plugin based solution in the next few days. –  Joost Schuur Jul 20 '11 at 0:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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