0

Looking at the code in feed-rss2.php and feeds-rss2-comments.php, after the header preamble, we have a Loop - eg in feeds-rss2-comments.php:

if ( have_comments() ) : while ( have_comments() ) : the_comment();
$comment_post = get_post($comment->comment_post_ID);
get_post_custom($comment_post->ID);

Where is the wp_comment_query object being created for this loop?

What I'm doing (following my question yesterday), is creating 2 new RSS feeds - one showing posts that have been trashed, the other showing comments that have been trashed. It's easy enough to add a new query_posts / get_comments call, but is there a more efficient way of doing it?

1 Answer 1

1

These files are not loaded directly, but similar to regular template files, only after the WP class is initialized. This class does the main query, which already can include the comments if the correct query variables are set.

The execution flow is a follows, starting in the main index.php:

require('./wp-blog-header.php');
    require_once( dirname(__FILE__) . '/wp-load.php' );
        // Initialization of settings, plugins, theme
    wp();
        WP::main();
            WP::init();
            WP::parse_request();
                // Parse `/feed/` and `/comments/feed/` and set the query variables
            WP::send_headers();
            WP::query_posts();
                WP::build_query_string();
                WP_Query::query();
                    WP_Query::init();
                    WP_Query::get_posts();
                        // This does the actual query
                        // `pre_get_posts` is the action you'll probably want to use
            WP::handle_404();
            WP::register_globals();
    require_once( ABSPATH . WPINC . '/template-loader.php' );
        if ( is_feed() ) {
            do_feed();
                // This calls the `do_feed_[feedtype]` action, e.g. rss2
                    do_feed_rss2( $for_comments );
                        if ( $for_comments )
                            load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' );
                        else
                            load_template( ABSPATH . WPINC . '/feed-rss2.php' );
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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