Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#46481 new defect (bug)

Empty response if page template return zero

Reported by: pattyland's profile pattyland Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1
Component: General Keywords:
Focuses: Cc:


Hello together, for an API that pulls data from WordPress, I created a page template that outputs a certain number based on the requested parameters. As long as this number is not equal to zero, everything is fine. But if the page template should output only "0", the WordPress page is completely empty. As soon as a space is added, e.g. "0 ", the output works again.

Attachments (1)

test_template.php (20 bytes) - added by pattyland 5 years ago.

Download all attachments as: .zip

Change History (3)

#1 @desrosj
5 years ago

  • Keywords reporter-feedback added

Hi @pattyland,

Can you provide more details? I am having a hard time understanding why you are creating files like you have provided, or how you are including them.

#2 @pattyland
5 years ago

  • Keywords reporter-feedback removed

Hi @desrosj,

sorry my short description. In my test case I wrote a small plugin to get a custom template for an url, like this:

add_filter( 'page_template', 'wptrac_page_template' );
function wptrac_page_template( $page_template )
    if ( is_page( 'my-custom-page-slug' ) ) {
        $page_template = dirname( __FILE__ ) . '/test_template.php';
    return $page_template;

Together with the attached test_template.php this template is used for the page "my-custom-page-slug" is copied from the snipped above.

I hope you unterstand me better now :)

Best regards,

Note: See TracTickets for help on using tickets.