is_preview() always return false

Raelynn: 5 days ago

I'm just starting out on a new Wordpress project and for some reason I can't get the previews working. I have disabled all of my plugins and still i always get false when using is_preview().

Currently I'm just creating a page that renders via page.php where I only call var_dump(is_preview()) and it always shows false. Doesn't matter if I put it in the loop either, still false. What am I missing here?

Shouldn't is_preview() return true when i click "Preview Changes"?

EDIT: I'm of course calling var_dump(is_preview()) and not "the_preview" as i orginially wrote. and it prints bool(false) every time.

RESOLVED: It was actually some misconfiguration in the nginx server running the site. Not sure exactly what it was, it's not my area of expertise so to speak. But the problem is resolved.

John: 5 days ago

is_preview() should return true is it is a preview. Did you try the following on the page.php?

if(is_preview()){ echo "preview" }else{ echo "no preview" }

to check if the is_preview() function is working?

EDIT2: You could work your way around it and check for:

if($_GET['preview'] == true){}