WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Exclude category from feed plus force full content? (13 posts)

  1. bmck
    Member
    Posted 8 years ago #

    My main feed includes all categories and is excerpt-only (in the spirit of RSS!). I'm trying to produce a feed for a specific syndication purpose, which needs my "asides" category (id=16) excluding and should be full content cf. excerpt-only.

    The first requirement, with help, I have address by editing index.php at root level to this:

    <?php
    define('WP_USE_THEMES', true);
    if(isset($_GET['feed'])) {
    if(isset($_GET['type_of_feed'])) {
    if ($_GET['type_of_feed']=='9rules'){
    $cat=-16;
    }
    }
    }
    require('.wp-blog-header.php');
    ?>

    Is it possible to modify this to achieve the second requirement, to force this particular feed to contain the full post?

  2. bmck
    Member
    Posted 8 years ago #

    Obviously a difficult question.

  3. bmck
    Member
    Posted 8 years ago #

    Evidently extremely challenging. I'll bet there isn't a single WP user visiting these forums who is remotely capable of answering this one, with a simple "Yes" or "No, it isn't possible". Not the case? Prove me wrong!

  4. bmck
    Member
    Posted 8 years ago #

    I've given up on changing index.php. I've reverted to the default. Here's the current situation:

    http://www.bioneural.net/feed/ will redirect correctly to FeedBurner (http://feeds.feedburner.com/Bioneuralnet).

    I want http://www.bioneural.net/9rules/feed/ to re-direct to a custom feed that excludes posts in category 16.

    I added the following to my .htaccess file:

    # Test to show bookmarks only
    RewriteBase /
    RewriteRule ^9rules/feed/?$ /index.php?&feed=rss2&cat=16 [R,L]

    This will correctly show cat 16 (bookmarks) only for http://www.bioneural.net/9rules/feed/

    # Create a feed for 9rules.com excluding bookmarks
    RewriteBase /
    RewriteRule ^9rules/feed/?$ /index.php?&feed=rss2&cat=-16 [R,L]

    This should show posts in all categories *except* in cat 16.

    However, it results in this:

    WordPress database error: [Not unique table/alias: 'wp_post2cat']
    SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND (category_id != 16) AND post_date_gmt <= '2006-07-20 10:10:59' AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static') AND post_status != "attachment" GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10

    Warning: Cannot modify header information - headers already sent by (output started at /home/.ashea/bioneural/bioneural.net/wp-includes/wp-db.php:102) in /home/.ashea/bioneural/bioneural.net/wp-rss2.php on line 8
    http://www.bioneural.net stuff worth sharing Tue, 18 Jul 2006 21:09:04 +0000 http://wordpress.org/?v=2.0.3 en

    Anyone?

  5. bmck
    Member
    Posted 8 years ago #

    OK, so I'm told this rewrite hack worked in WP 1.x but broke in WP 2.x

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    I don't think you're on the wrong track here. I didn't know that the -cat trick would work for feeds, but it does on my blog, so it should on yours too.

    Try this URL: http://www.bioneural.net/index.php?feed=rss2&cat=-16

    If that doesn't work, I suspect that your feed redirection to feedburner is the real problem here.

  7. bmck
    Member
    Posted 8 years ago #

    Otto42 thanks, no, I already tried that URL and I get the same WP database error as above. You may be right about implicating the FeedBurner redirection (which I want to keep). In any case I have finally resolved this and now offer a excerpt-only feed for all categories, and a full-text feed excluding category 16 (bookmarks).

    Details here.

  8. WPChina
    Member
    Posted 8 years ago #

    This thread looks really promising, but I'm a little lost. I am trying to exclude 2 categories from my feed.

    Would I just write this to exclude the categories?
    $cat=-8,-14;

    Where exactly would I add that?

  9. bmck
    Member
    Posted 8 years ago #

    your.site.com/index.php?feed=rss2&cat=-8,-14 as the URL might work. Maybe it depends on which version of WordPress you use. Maybe on whether your redirect to FeedBurner. Maybe on the phase of the Moon?

  10. WPChina
    Member
    Posted 8 years ago #

    Right, I could do that... but I want the default feed to omit these categories instead. I want people to visit your.site.com/index.php?feed=rss2 directly and not find these 2 categories... is this possible? I don't want people to have to add stuff to the end of the URL...

  11. bmck
    Member
    Posted 8 years ago #

    Can you edit your .htaccess file? If so this might work:

    # Re-direct default feed to exclude cats 8 and 14
    RewriteBase /
    RewriteRule ^feed/?$ /index.php?&feed=rss2&cat=-8,-14 [R,L]

    So anyone who clicks on your default feed link (http://your.site.com/feed/) should get re-directed to:

    http://your.site.com/index.php?feed=rss2&cat=-8,-14

    Please let me know if this does work. If so, then the reason it does NOT work for me must be to do with my FeedBurner re-direction.

  12. aflusche
    Member
    Posted 7 years ago #

    For future reference, I was able to exclude a category while still using FeedBurner. I just edited the FeedBurner source feed to be:

    http://your.site.com/index.php?feed=rss2&cat=-N

    (where N is the category number to exclude)

    It's looking good so far. If I run into any problems, I'll post back here.

  13. oncidium
    Member
    Posted 7 years ago #

    I'm trying to do this same thing. Did the final solution work?

Topic Closed

This topic has been closed to new replies.

About this Topic