How to not load comments form on post preview?

Posted in: Newsmag
Post count: 93

I need a way not to load the comments form when previewing a post, is there a way to achieve this? How?

If you need a reason to help: I use disqus and it generates a url for the “discussion” the first time the comment form loads, if this is the preview then it will look something like site.com/?post_type=food&p=41009 And this is a problem because afterwards when the post is published under a real url disqus will not recognize the comments count. The only way is to manually change the discussion url. I’ve already contacted disqus and they say, “not a bug” if you do not want disqus to pick the preview url, don’t load disqus on the preview page, the only way i know is to completely remove the comments form, so how would i go about this? Is there some sort of conditional for the preview page?

Post count: 6535

HI

You can make a detect using this code: http://screencast.com/t/zYuWvLQh5Whttp://screencast.com/t/E1ZzSq7mhFlj

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

if ($preview == true){
	echo '<h1> this is preview mode </h1>';
}

Inside second condition you need to add a code which will prevent disqus to load in preview mode.
Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newsmag’ is closed to new topics and replies.