/** * Start the buffer for content replacement on the Social Paper archive page. * * @access private * * @param WP_Query $q */ function _cacsp_archive_ob_start($q) { if (false === cacsp_is_archive()) { return; } // be careful with other WP_Query loops on the page if (empty($q->query['post_type']) || 'cacsp_paper' !== $q->query['post_type']) { return; } if (true === Social_Paper::$is_buffer) { return; } Social_Paper::$is_buffer = true; remove_action('loop_start', '_cacsp_archive_ob_start', -999); ob_start(); }