I've got some documentation stored in a WordPress install for something I'm developing, and I want to have a pure html, single page version of it in addition to the regular templated version which is navigated more like a blog. The idea of the pure html single page version is to be able to save it and include it with the product.

The documentation is contained in 19 posts of a custom post type called articles.

I've got the following functions in functions.php to set a few query vars on the articles post type.

// Always sort articles by menu_order
function sort_articles_by_menu_order( $query ) {
    if( 'articles' == get_query_var( 'post_type' ) ) {
        $query->set( 'orderby', 'menu_order' );
        $query->set( 'order', 'ASC' );
    return $query;
add_action( 'pre_get_posts', 'sort_articles_by_menu_order' );

// Output all posts on html docs tpl
function get_all_docs( $query ) {
    if( isset( $_GET['html'] ) ) {
        $query->set( 'posts_per_page', -1 );
    return $query;
add_action( 'pre_get_posts', 'get_all_docs', 9999 );

I've also got the following function that checks for ?html in the URL and switches to my single-page template.

// Use HTML template for articles if URL paramater set
function html_docs_template_redirect( $template ) {
    if( isset( $_GET['html'] ) ) {
        $new_template = locate_template( array( 'html-docs.php' ) );
        if ( '' != $new_template ) {
            return $new_template ;
    return $template;
add_action( 'template_include', 'html_docs_template_redirect' );

The html-docs.php template is pretty basic, it is just a html shell with the loop in the middle. It does not include get_header(), language_attributes() or get_footer().

The problem is that if I use the_content() or apply_filters( 'the_content', get_the_content() ), WordPress only returns some of the posts, then stops all output (doesn't even finish outputting the page template like </body></html> etc). In Chrome's console I see this error:


If I comment out the parts that get the content, everything works fine. Even if I call get_the_content() without applying filters it works fine.

I've also tried using a different server with the same results.

My template file - though I don't think this is where the problem lies.

<!doctype html>
    <meta charset="UTF-8">
    <title>Aptus Documentation</title>
    <style type="text/css">
        /* Styles Omitted */

    <main id="main">
        <header id="header">
            <h1>Aptus Documentation</h1>

        <?php // Loop outputs content and stores nav
        $contents = '';
        if (have_posts()) : while (have_posts()) : the_post();

            $contents .= '<li><a href="#' . $post->post_name . '">';
                $contents .= get_the_title();
            $contents .= '</a></li>';

            <article id="<?php echo $post->post_name; ?>" class="doc">
                <div class="doc-inner">
                    <h1><?php the_title(); ?></h1>
                    <?php the_content(); ?>
                    <?php //echo apply_filters( 'the_content', get_the_content() ); ?>

        <?php endwhile; endif; ?>


    <nav id="sidebar">
        <div class="sidebar-inner">
                <?php echo $contents; ?>


I think I have also ruled out an encoding problem in the content of one of the posts, because depending on different things I try it stops output at a different post (it seems to just output a certain number of bytes before stopping).

I am lost on this so would appreciate suggestions.

  • Some quick Googling for net::ERR_INCOMPLETE_CHUNKED_ENCODING brought up this page which suggests it could be a server issue (though you say you've tried a different server -- a different physical server, or a different software server (eg, nginx vs apache)?), and this, whose comments suggest a loose network cable or an overzealous anti-virus package. Any of those help?
    – Pat J
    May 29, 2014 at 2:07
  • Thanks, I had read both of those pages. I've only tried two Apache servers (one of which was MAMP). I've also sent a live link off for others to check for me to see if it's to do with my internet connection or local setup, but haven't heard back yet.
    – GusRuss89
    May 29, 2014 at 2:51

1 Answer 1


Ok I eventually discovered it was due to some shortcodes in a couple of the documentation articles. I escaped them with double square braces [[example]] and everything works as it should now.

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.